Install and configure the MySQL database in linux
1. decompress the file to the current directory.
Command: tar-zxvf mysql...tar.gz
2. Move the decompressed folder to the target directory and rename mysql
Command: mv mysql-version/usr/local/mysql
Add system mysql group and mysql user
Add a system mysql Group
sudo groupadd mysql
Add a mysql user
sudo useradd -r -g mysql mysql
You can view the id mysql after adding it.
Then go to the/usr/local/mysql directory.
Set the permission of the mysql user group to operate on the folder
Command:chown -R mysql:mysql ./
Check whether/etc/my. cnf exists. If yes, delete it.
Command: ls/etc/my. cnf
DELETE command: rm/etc/my. cnf
Initialize Database
Command:./scripts/mysql_install_db --user=mysql
Note: If you run this command, the following error is reported:
Install the yum package
Command:yum -y install perl perl-devel
After installation, run the database initialization command again.
Then go to the support-files folder.
Copy my-default.cnf to/etc and rename it my. cnf
Command:cp my-default.cnf /etc/my.cnf
Copy the Startup File mysql. server to/etc/rc. d/init. d and rename it mysql.
Command:cp mysql.server /etc/rc.d/init.d/mysql
Then configure mysql to start automatically
Go to the/etc/init. d directory.
Grant executable permissions to mysql
Command:chmod +x mysql
Add Service
Command:chkconfig --add mysql
View service list
Command:chkconfig --list
If you see mysql services, and all 3, 4, and 5 are on, the operation is successful. If it is off, Type
chkconfig --level 345 mysql on
Restart your computer
Check the listener to check whether the service is started
Command:netstat -na |grep 3306
You can change the database remotely.
Authorized Operation
Command:grant all privileges on *.* to '%'@'%' identified by 'mypassword' with grant option;
Refresh authorization
Flush privileges;
Remote connection
Delete other users
Summary
The above section describes how to install and unzip the MySQL database in linux. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!