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.7CentOSMySql
- Centos7下安裝配置MySQL5.7CentOSMySql
- CentOS7利用docker安裝MySQL5.7CentOSDockerMySql
- centos7安裝mysql5.7 使用yumCentOSMySql
- CentOS7 透過YUM安裝MySQL5.7CentOSMySql
- CentOS7下MySQL5.7安裝與配置(YUM)CentOSMySql
- Centos7系統如何安裝MySQL5.7資料庫?CentOSMySql資料庫
- CentOS7 64位下MySQL5.7安裝與配置(YUM)CentOSMySql
- 騰訊雲centos7安裝mysql5.7,並開啟3306埠CentOSMySql
- centos安裝mysql5.7CentOSMySql
- mysql5.7 安裝教程MySql
- Centos7安裝Mysql5.7 提示GPG 金鑰不存在/不合適CentOSMySql
- Windows安裝MySQL5.7教程WindowsMySql
- linux離線安裝mysql5.7LinuxMySql
- CentOS7.3 安裝 MySQL5.7CentOSMySql
- MySQL5.7綠色版安裝MySql
- windows安裝及配置mysql5.7WindowsMySql
- ubuntu16 安裝mysql5.7UbuntuMySql
- CentOS7安裝php、安裝MySqlCentOSPHPMySql
- Centos7安裝安裝部署dockerCentOSDocker
- 基於centos7的MySQL5.7二進位制安裝包的本地升級CentOSMySql
- MySQL:mysql5.7解壓版安裝與解除安裝MySql
- 基於centos7的MySQL5.7二進位制安裝包的邏輯升級CentOSMySql
- centos7.6 安裝配置 mysql5.7CentOSMySql
- centos7.2 mysql5.7安裝教程CentOSMySql
- centos7安裝nginxCentOSNginx
- Centos7 安裝 NginxCentOSNginx
- centos7 安裝 rcloneCentOS
- centos7安裝mysqlCentOSMySql
- centos7 安裝rocketmqCentOSMQ
- centos7安裝supervisorCentOS
- centos7安裝composerCentOS
- CentOS7安裝RedisCentOSRedis
- CentOS7 安裝 dockerCentOSDocker
- centos7安裝dockerCentOSDocker
- Centos7安裝RabbitMQCentOSMQ