CentOS 6.5 is a very popular Linux operating system version. Many people choose to use CentOS 6.5 as their server operating system, so installing MySQL on this system is an essential task. This article will provide detailed steps to help you install MySQL on CentOS 6.5.
The easiest way to install MySQL on CentOS 6.5 is through the yum package manager. First, we need to open a Linux terminal and enter the following command to install MySQL:
sudo yum install mysql-server
This command will start the MySQL installation program and download and automatically install MySQL. We need to wait for a while, during which you will be prompted for the root user password and the MySQL administrator password.
After the installation process is completed, we need to start the MySQL service. Start MySQL through the following command:
sudo service mysqld start
If the installation is successful, you will see the following information:
Starting mysqld: [ OK ]
Default , the MySQL server will not allow access from the public network. Therefore, we need to configure the following to make MySQL accessible from other computers.
Open the MySQL configuration file and execute the following command:
sudo nano /etc/mysql/my.cnf
Find the following line in this file:
bind-address = 127.0.0.1
Change it to:
# bind-address = 127.0.0.1
This Will allow MySQL to accept connection requests from other computers. Save changes and exit the file.
Restart the MySQL service for the changes to take effect:
sudo service mysqld restart
Now, you have successfully installed MySQL on CentOS 6.5 and With this configured, we can create a new MySQL database. We need to enter the interactive shell of MySQL using the following command:
sudo mysql -u root -p
This will ask you to enter your MySQL administrator password. After entering your password, you will see the following command prompt:
mysql>
We need to create a new MySQL database. Execute the following command:
CREATE DATABASE mydatabase;
You can replace mydatabase with the name of the database you need to create.
Now, we need to create a new MySQL user so that the database can be accessed. Execute the following command to create a new MySQL user:
CREATE USER 'myusername'@'%' IDENTIFIED BY 'mypassword';
Replace myusername and mypassword with the MySQL username and password you want to create, and remember these credentials.
We also need to assign permissions to the new user. Execute the following command:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myusername'@'%';
Replace myusername and mydatabase again with your MySQL username and database name.
To ensure the security of the MySQL database, we should delete the default MySQL user account and use a stronger MySQL password policy.
Delete default account:
DROP USER ''@'localhost'; DROP USER ''@'yourhostname';
Modify MySQL password policy:
SET GLOBAL validate_password_policy=LOW;
Now, you have successfully MySQL is installed on CentOS 6.5, and a new MySQL database and user have been created. You can use the following command to connect to a MySQL server:
mysql -u myusername -p -h IP地址 mydatabase
Replace myusername and mydatabase with the MySQL user and database names you just created. Replace IP address with the IP address of your CentOS 6.5 server.
If you successfully connect to the MySQL server, you have completed the process of installing MySQL on CentOS 6.5.
Conclusion
MySQL is a popular relational database that is often used as a backend for server-side applications. Installing MySQL on CentOS 6.5 is an important task as it is a popular server operating system. This article provides detailed steps to help you install MySQL on CentOS 6.5 and create a new database and user to be able to connect to the MySQL server and start using it.
The above is the detailed content of How to install mysql on centos6.5. For more information, please follow other related articles on the PHP Chinese website!