Configure mysql under linux

1. Download mysql

wget http

2. Check whether the mariadb database is installed in linux, the mariadb database is a branch of mysql

yum list installed | grep mariadb

If the mariadb database is installed in linux, it may conflict with the installation of the mysql database

yum -y remove mariadb (mariadb is the package detected earlier)

3. Unzip

The location of the cd archive

tar -zxvf mysql.*.*.*.2.1.tar.gz -C /usr/local (specify the decompression location)

4. Rename the extracted folder

cd Unzipped folder location (mysql+version number (assuming mysql.1.2) )

mv mysql.*.*.*.2.1 mysql.2.1

5. Create a folder data under mysql.1.2

cd mysql.2.1

mkdir data

6. Add a user (in the mysql.2.1 directory)

useradd mysql

7. Switch to the mysql.2.1/bin directory to execute

./mysqld --initialize --user=mysql --datadir=/usr/local/mysql.2.1/data --basedir=/usr/local/mysql.2.1

Note: You will get an initialization password and you must remember it, otherwise you will not be able to connect to the database

8. Switch to the mysql.2.1/bin directory to execute

./mysql_ssl rsa_setsetup  --datadir=/usr/local/mysql.2.1/data

9. Change the permissions of the entire folder of mysql.2.1

chown -R mysql: mysql /usr/local/mysql.2.1

10. Start the mysql service

./mysqld_safe & (& means background start)

11. Switch to the mysql.2.1/bin directory to perform login

./mysql -uroot -p

Enter the temporary password generated in step 7

12. Execute the sql statement show database, an error will occur, prompting to change the password

alter user 'root'@'localhost' indentified by '123456'

13. Authorize Remote Access

grant all privileges on *.* to root@'%' indentified by '123456'

The first * sign indicates all database names

The second * sign indicates all database tables

 root@'%': root means username % means ip address, such as root@localhost,[email protected]

14. Execute the refresh permission command

flush privileges

Guess you like

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