Home  >  Article  >  Database  >  centos 6.5 install mysql

centos 6.5 install mysql

WBOY
WBOYOriginal
2023-05-14 09:15:37832browse

CentOS 6.5 is a popular Linux operating system that can be used to build servers and run various applications. One of the common use cases is installing a MySQL database. In this article, we will explain how to install MySQL on CentOS 6.5 and list some tips for solving common problems.

Step One: Install MySQL

Installing MySQL on CentOS 6.5 is very simple. Simply run the following command:

sudo yum install mysql-server mysql

This command will install the MySQL server and client software from the default repository.

Step 2: Start MySQL

After the installation is complete, you can use the following command to start the MySQL server:

sudo service mysqld start

This command will start the MySQL server process.

Step 3: Set up MySQL

Now, you need to open MySQL, set a root password and make some other configurations.

Run the following command to open MySQL:

sudo mysql_secure_installation

The command will prompt you for your current root password and then prompt you if you want to change it. If you have not set a password, press Enter to continue.

Next, you will be asked if you want to delete the anonymous user account. Choose based on your needs.

You will then be asked to not allow the root user to access the MySQL server through remote connections. Unless you have special requirements, select "Yes".

Finally, you will be asked to refresh the permissions table and delete the test database. Just follow the prompts.

Step Four: Test MySQL

Now that you have successfully installed and set up the MySQL server, you can test that it is running using the following command:

sudo service mysqld status

If everything OK, you should see the "MySQL service is running" message.

In addition, you can also use the following command to log in to MySQL:

mysql -u root -p

Enter the root password you set to log in to the MySQL client.

FAQ

1. Unable to start MySQL server

If you cannot start the MySQL server, you can check the error log file to see what the problem is.

The log file is located at /var/log/mysqld.log. Use the following command to view the contents of the file:

sudo less /var/log/mysqld.log

Search the log file for error messages to identify the problem. This can be caused by configuration issues, permission issues, file corruption, etc.

2. Unable to connect to MySQL

If you cannot connect to the MySQL server, you can perform the following steps:

  • Check the firewall settings to ensure that the MySQL port (default is 3306) is open.
  • Check whether the MySQL server is running. If it is not running, start it.
  • Check the MySQL configuration file to make sure it allows remote connections. You can find this file in /etc/mysql/my.cnf.

3. Forgot the root password

If you have forgotten the root password for MySQL, you can reset it using the following steps:

  • Stop the MySQL server process.
  • Start the MySQL server and skip password verification.
  • Enter MySQL and update the root password.

Here are the specific steps:

sudo service mysqld stop
sudo mysqld_safe --skip-grant-tables &
mysql -u root
UPDATE mysql.user SET Password=PASSWORD('your_new_password') WHERE User='root';
FLUSH PRIVILEGES;
exit;
sudo service mysqld start

The above command will allow you to skip password verification to start the MySQL server and then update the root password. Afterwards, you can stop the MySQL server process and restart it.

Conclusion

Installing MySQL on CentOS 6.5 is very simple. It only takes a few commands to do it. But if you run into a problem, you now know how to fix it. Now that you have a server running MySQL, you can proceed with building and running your application.

The above is the detailed content of centos 6.5 install mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:mysql renameNext article:mysql rename