Recently, the project applied for Cloud Server. The boss asked me to set up the environment. I encountered a little bit more pits when installing MySql, so I will make a record here. My installation method is not to install through the installation package, but through yum to install, so that can save a lot of things, let's talk about the specific installation process.
1. Uninstall the original mysql |
---|
Because the mysql database is so popular on Linux now, the mainstream Linux system versions currently downloaded basically integrate the mysql database in it, we can use Use the following command to check whether the mysql database has been installed on our operating system;
rpm -qa | grep mysql //This command will check whether the mysql database has been installed on the operating system
If yes, we will uninstall it through rpm -e command or rpm -e --nodeps command
rpm -e mysql //Normal delete mode
rpm -e --nodeps mysql //Forced deletion mode, if you use the above command to delete other files that are dependent on it, you can use this command to delete it forcefully
After deleting, we can use the rpm -qa | grep mysql command to check whether mysql has been uninstalled successfully! !
Two, install mysql through yum |
---|
At the beginning, it was installed directly through this command:
yum install mysql mysql-server mysql-devel
The installation of mysql and mysql-devel were successful, but the installation of mysql-server failed, as follows:
[ localhost ~]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.sina.cn
* extras: mirrors.sina.cn
* updates: mirrors.sina.cn
No package mysql-server available.
Error: Nothing to do
Checking the information found that the CentOS 7 version removed the MySQL database software from the default program list. There are two ways to solve it. Use **MariaDB instead, the other way is from the official website Download and install
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm //Download the YUM library
yum localinstall -y mysql57-community-release-el7-7.noarch.rpm //Install YUM library
yum install -y mysql-community-server //Install the database
systemctl start mysqld.service //Start the database service
mysql -uroot -p //Default empty password
Restart the mysql service after resetting the root password:
update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";
flush privileges;
quit;
systemctl restart mysqld;
At this time there was a problem:
ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: NO)
Please modify my.cnf and add skip-grant-tables and skip-networking:
vi /etc/my.cnf
[ mysqld]
skip-grant-tables
skip-networking
Restart mysql and repeat the above steps to modify the password. Remember to remove the two lines added by my.cnf after the modification. If you have other questions, you can refer to this blog for details: http://www.cnblogs.com/ivictor/p/5142809.html
Three, add remote login users |
---|
After completing the above steps, that is to use locally, if you want to connect remotely, you need to do specific configuration.
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Your password' WITH GRANT OPTION;
Note:'%'Represents any address, IP can also be specified
Check user table, refresh memory permissions
select host, user from user;
FLUSH PRIVILEGES;
Now, the database is ready for use. In the future, you can set up a firewall or encoding format.
Turn off the firewall
centos 7:
systemctl stop firewalld.service #stop
systemctl disable firewalld.service #Disable
previous version:
service iptables stop #stop
chkconfig iptables off #Disable
View the status of mysql:
* View current mysql running status
mysql>status
Parameter Description:
haracter_set_client: The character set of the data requested by the client.
character_set_connection: The character set of the data received from the client and then transmitted.
character_set_database: The character set of the default database, no matter how the default database is changed, it is this character set; if there is no default database, use character_set_The character set specified by the server, this parameter does not need to be set.
character_set_filesystem: Convert the file name on the operating system into this character set, that is, the character_set_client conversion character_set_filesystem, the default is binary.
character_set_results: The character set of the result set.
character_set_server: The default character set of the database server.
character_set_system: This value is always utf8 and does not need to be set. The character set for storing system metadata.
Recommended Posts