Centos install mysql database

1. Download the repo source of mysql

$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2. Install the mysql-community-release-el7-5.noarch.rpm package

$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

3. Install mysql

$ sudo yum install mysql-server

4. After the installation is complete, set the boot to start automatically

$ chkconfig mysqld on

5. Start mysql

$ service mysqld start

6. Set the root account password

/usr/bin/mysqladmin -u root password "root"

7. Log in to the mysql database

$ mysql -uroot -p

enter password

8. Create a database

mysql> CREATE DATABASE demo;

9. Create a new user (user) for the already created MySQL database

mysql> CREATE USER user@localhost;

10. Set the password "hyh911202" for this user.

mysql> SET PASSWORD FOR user@localhost=PASSWORD("hyh911202");

11. Provide full access to the database "demo" for the created user.

mysql> GRANT ALL PRIVILEGES ON demo.* TO user@localhost IDENTIFIED BY 'hyh911202';

12. Use the following commands to make all configurations take effect.

mysql> FLUSH PRIVILEGES;

13. Exit

mysql> exit

 

Guess you like

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