mysql5.7安裝_centos7
1、oracle官網下載社群版,generic為正式版
2、 修改主機名,更改hosts檔案
hostnamectl set-hostname dbserver echo "xx.xx.xx.xxx dbserver" >> /etc/hosts
xx.xx.xx.xxx為你自己的ip
3、解除安裝主機自帶mysql
rpm -qa | grep *mysql* rpm -e --nodeps mysql rpm -qa | grep mariadb* rpm -e --nodeps mariadb
4、安裝mysql5.7
mkdir -p /u01/app/ mkdir -p /u01/data/3306 mkdir -p /u01/log/3306 tar xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.28-linux-glibc2.12-x86_64 /u01/app/mysql
5、建立mysql使用者組,目錄授權
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown -R mysql:mysql /u01
vi ~/.bash_profile
PATH=$PATH:/u01/app/mysql/bin:$HOME/bin
6、配置引數檔案
[root@dbserver mysql]# cat /u01/data/3306/my.cnf [mysql] default-character-set=utf8 socket=/u01/data/3306/mysql.sock [mysqld] #skip-name-resolve port = 3306 socket=/u01/data/3306/mysql.sock basedir=/u01/app/mysql datadir=/u01/data/3306/data character-set-server=utf8 default-storage-engine=INNODB innodb_buffer_pool_size = 200M max_allowed_packet=16M explicit_defaults_for_timestamp=1 log-output=FILE general_log = 0 general_log_file=/u01/log/3306/3306db-general.err slow_query_log = ON slow_query_log_file=/u01/log/3306/3306db-query.err long_query_time=10 log-error=/u01/log/3306/3306db-error.err [root@dbserver mysql]#
vi /u01/data/3306/my.cnf
[mysql]
default-character-set=utf8
socket=/u01/data/3306/mysql.sock
[mysqld]
#skip-name-resolve
port = 3306
socket=/u01/data/3306/mysql.sock
basedir=/u01/app/mysql
datadir=/u01/data/3306/data
character-set-server=utf8
default-storage-engine=INNODB
innodb_buffer_pool_size = 200M
max_allowed_packet=16M
explicit_defaults_for_timestamp=1
log-output=FILE
general_log = 0
general_log_file=/u01/log/3306/3306db-general.err
slow_query_log = ON
slow_query_log_file=/u01/log/3306/3306db-query.err
long_query_time=10
log-error=/u01/log/3306/3306db-error.err
7、mysql資料庫初始化
ln -sf /u01/data/3306/my.cnf /etc/my.cnf /u01/app/mysql/bin/mysqld --initialize --user=mysql --basedir=/u01/app/mysql/ --datadir=/u01/data/3306/data/
8、配置CENTOS linux啟動和停止指令碼
vi /usr/lib/systemd/system/mysqld.service
[Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev/mysql/doc/refman/en/using-sysemd.html After=syslog.target After=network.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/u01/app/mysql/bin/mysqld --defaults-file=/u01/data/3306/my.cnf LimitNOFILE = 65536 LimitNPROC = 65536
9、配置systemctl 啟動和停止指令碼方法
systemctl daemon-reload
systemctl stop mysqld
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
手動啟動和停止mysql的方法
nohup /u01/app/mysql/bin/mysqld_safe --defaults-file=/u01/data/3306/my.cnf &
mysqladmin -uroot -p shutdown -S /u01/data/3306/mysql.sock
10、修改root密碼
mysql -uroot -p
初始密碼可以在檔案/u01/log/3306/3306db-error.err中檢視
alter user 'root'@'localhost' IDENTIFIED BY 'rootroot';
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
11、允許root使用者遠端登陸
mysql -uroot -p use mysql select host,user from user where user='root'; create USER 'root'@'%' identified by 'rootroot'; grant all privileges on *.* to 'root'@'%' with grant option; exit mysql -uroot -p -h10.8.98.150
遠端的話記得開放防火牆3306埠
12、建立資料庫,建立使用者,檢視使用者,分配許可權
create database testdb default charset utf8mb4
create user 'testuser'@'%' identified by 'testtest';
select host,user from mysql.user;
grant all privileges on testdb.* to 'testuser'@'%' identified by 'testtest';
grant all privileges on testdb.* to 'testuser'@'localhost' identified by 'testtest';
建立表
use testdb
create table testtbs(
id int auto_increment primary key,
name varchar(15)
) engine= InnoDB;
插入資料
insert into testtbs values(1,'test01');
insert into testtbs values(2,'test02');
insert into testtbs values(3,'test03');
commit;
查詢資料
select * from testdb.testtbs;
use testdb;
select * from testtbs;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70004783/viewspace-2794003/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- CentOS7 安裝mysql5.7CentOSMySql
- CentOS7 yum安裝MySQL5.7CentOSMySql
- centos7安裝mysql5.7 使用yumCentOSMySql
- CentOS7利用docker安裝MySQL5.7CentOSDockerMySql
- Centos7下安裝配置MySQL5.7CentOSMySql
- 在centos7上安裝mysql5.7CentOSMySql
- CentOS7 透過YUM安裝MySQL5.7CentOSMySql
- CentOS7下MySQL5.7安裝與配置(YUM)CentOSMySql
- centos7安裝mysql5.7解壓縮版CentOSMySql
- CentOS7 64位安裝mysql5.7(linux)CentOSMySqlLinux
- Centos7系統如何安裝MySQL5.7資料庫?CentOSMySql資料庫
- CentOS7 64位下MySQL5.7安裝與配置(YUM)CentOSMySql
- Centos7安裝Mysql5.7 提示GPG 金鑰不存在/不合適CentOSMySql
- Centos7安裝Mysql5.7方法總結 - 實操手冊CentOSMySql
- mysql5.7 安裝教程MySql
- centos安裝mysql5.7CentOSMySql
- 騰訊雲centos7安裝mysql5.7,並開啟3306埠CentOSMySql
- Windows安裝MySQL5.7教程WindowsMySql
- Centos7安裝安裝部署dockerCentOSDocker
- CentOS7.3 安裝 MySQL5.7CentOSMySql
- MySQL5.7綠色版安裝MySql
- ubuntu16 安裝mysql5.7UbuntuMySql
- windows安裝及配置mysql5.7WindowsMySql
- 基於centos7的MySQL5.7二進位制安裝包的本地升級CentOSMySql
- MySQL:mysql5.7解壓版安裝與解除安裝MySql
- 安裝centos7最小化安裝CentOS
- 基於centos7的MySQL5.7二進位制安裝包的邏輯升級CentOSMySql
- CentOS7 安裝 memcacheCentOS
- Centos7安裝nginxCentOSNginx
- CentOS7 安裝 dockerCentOSDocker
- CentOS7 安裝 MySQLCentOSMySql
- CentOS7安裝RedisCentOSRedis
- Centos7 安裝ffmpegCentOS
- centos7安裝protobufCentOS
- 4.1 CentOS7安裝CentOS
- CentOS7 安裝NginxCentOSNginx
- centos7 安裝pipCentOS
- Centos7安裝RabbitMQCentOSMQ