Mysql on how to deploy Linux servers

First, install mysql

  1 by file upload tool, mysql linux installation package uploaded to the server

  2. Uninstall MariaDB package, due to package MariaDB cause the system error mariadb-libs substituted mysql-community-libs-8.0.11-1.el7.x86_64 when mysql installation, it will uninstall

  命令: # yum remove mariadb*

  3. Extract the installation package mysql

  Command: # tar -xvf mysql-8.0.15-1.el7.x86_64.rpm-bundle.tar

  4. unpack several .rpm, run the following command sequence order

  # rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm

  

  # rpm -ivh mysql-community-libs-8.0.15-1.el7.x86_64.rpm

  

  # rpm -ivh mysql-community-devel-8.0.15-1.el7.x86_64.rpm --nodeps --force  

  

  # rpm -ivh mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm

  

  # rpm -ivh mysql-community-client-8.0.15-1.el7.x86_64.rpm  

  

  # rpm -ivh mysql-community-server-8.0.15-1.el7.x86_64.rpm --nodeps --force  

  

Second, change the root password

  First, initialize the mysql database

  # mysqld --initialize --user=mysql

  View data stored directory

  # We /etc/my.cnf

   

  datadir = / var / lib / mysql, this directory is the data stored into the directory

  View initial random passwords

  # cat /var/log/mysqld.log

     

  Initial password is: VeGo * 7 + i &: d *

  Start mysql service

  # service mysqld start

  Edit my.cnf file, add the skip-grant-tables (the purpose is to avoid close Login)

  # We /etc/my.cnf

  

  Restart mysql

  # service mysqld restart

  No user password

  # Mysql -uroot -p (click on the Enter password is blank)  

  

  Select the database: mysql> use mysql;

  Change the root password: mysql> ALTER user 'root' @ 'localhost' IDENTIFIED BY 'abc123,'

  (Mysql8.0 more sensitive password policy restrictions must add digital special symbols)

  Exit mysql: mysql> quit

  Edit /etc/my.cnf, delete skip-grant-tables to save and exit, so far completed the password change.

Third, add new users and give permissions

  Enter the mysql command line, enter the root, and the password just set

  # mysql -uroot -p 

  After a successful login, switch databases.

  mysql> use mysql;

   Query User

  mysql> select host,user from user;

  Create users and assign permissions (for example: User: abc, password: abc123,)

  mysql> create user abc identified by ‘abc123,’;

  mysql> GRANT all ON *.* TO 'adcc'@'%';

  mysql> flush privileges;

  ⑤ view permissions of user adcc

  mysql> show grants for abc;

  Modify the permissions as% successful,% means that allow everyone to access

Fourth, set the boot

  # vim /etc/rc.local

  Add service mysqld start

  

 

 

I want to remember off by remote access firewall ah

CentOS 7.0 is the default firewall as a firewall

Check firewall status

# firewall-cmd --state

Stop firewall

# systemctl stop firewalld.service

Prohibit firewall boot

# systemctl disable firewalld.service 

 

Guess you like

Origin www.cnblogs.com/lmqblogs/p/11698707.html