MySql installation based on CentOS6 (any host can log in to MySQL)

Installation package preparation

  1. In order to ensure the purity of the system before installation, check whether mysql is installed. If it is installed, uninstall mysql and
    check: rpm -qa|grep mysql
    uninstall: rpm -e --nodeps {installation file found}
  2. Download MySql related installation packages
    MySQL-server-5.6.40-1.el6.x86_64 and MySQL-client-5.6.40-1.el6.x86_64
Install MySql server

  1. Install mysql server
    rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
  2. View the generated random password
    cat /root/.mysql_secret
  3. View mysql status
    service mysql status
  4. start mysql
    service mysql start
Install MySql client

  1. Install mysql client
    rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm
  2. link mysql
    mysql -uroot -pOEXaQuS8IWkG19Xs (random password seen above)
  3. Modify password
    mysql>SET PASSWORD=PASSWORD('666666');
  4. Exit mysql
    mysql>exit
Host configuration in the user table in MySql
As long as the configuration is root user + password, you can log in to the MySQL database on any host.
  1. Enter mysql
    mysql -uroot -p666666
  2. Show databases
    mysql>show databases;
  3. Use mysql database
    mysql>use mysql;
  4. Display all tables in the mysql database
    mysql>show tables;
  5. Show the structure of the user table
    mysql>desc user;
  6. Modify the user table and modify the content of the Host table to%
    mysql>update user set host='%' where host='localhost';
  7. 删除root用户的其他host
    mysql>delete from user where Host='hadoop102 ';
    mysql>delete from user where  Host='127.0.0.1';
    mysql>delete from user where  Host='::1';
  8. flush and launch
    mysql>flush privileges;
    mysql> quit;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325766020&siteId=291194637