Use yum to install mysql under Centos

Install mysql

# Download and install mysql official Yum Repository
wget -i -c
yum -y install mysql57-community-release-el7-10.noarch.rpm

#Install mysql directly
yum -y install mysql-community-server

mysql start

service mysqld start

View mysql status

service mysqld status
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-11-09 10:22:33 CST; 5s ago
     Docs: man:mysqld(8)
  Process: 8085 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/ $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 8031 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 8089 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─8089 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/

The running status indicates that MySQL is running, but to connect and use mysql, you need to find the user name and password of MySQL

View default password

grep "password" /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: hOa9fsoqgS=6

The default password is: hao9fsoqgs = 6

Landing mysql

# command
mysql -uroot -p  #Enter the above password

Change Password

By default, MySQL must modify the password to operate the database, so the password must be modified

ALTER USER 'root'@'localhost' IDENTIFIED BY '9^B6SuztL3j2%P$s';

Of course, the following prompts may appear during password modification

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

The reason is that your password does not conform to the built-in specification of mysql. The built-in specification is not mentioned here. Just set the password as complex as possible

Visualizer login authorization

If you want to use external tools to connect to mysql, you need additional authorization

grant all on *.* to root@'%' identified by 'Database password';

Set character set

Set the mysql character set to UTF-8, otherwise Chinese will be garbled. Exit mysql and edit the mysql configuration file with the following command

vi /etc/my.cnf

Tags: MySQL yum RPM Database

Posted on Sat, 09 Nov 2019 09:08:07 -0500 by fukas