Installing MySQL in CentOS5.4 has two options: 1. Installing MySQL based on the source code package (I .e. the tar package); 2. Installing MySQL based on the RPM package;
Installing MySQL in CentOS5.4 has two options: 1. Installing MySQL based on the source code package (I .e. the tar package); 2. Installing MySQL based on the RPM package;
1. Install MySQL database
You can install MySQL in CentOS5.4 in either of the following ways:
1. Install MySQL based on the source code package (I .e. the tar package;
2. MySQL installation Based on RPM packages;
The following describes how to install the source code package:
1. Unzip: tar-xzvf mysql-5.5.10-linux2.6-x86_64.tar.gz
2. Copy the unzipped installation package to the/usr/local directory (the installation directory of common software) and rename it to mysql.
Music mysql-5.5.10-linux2.6-x86_64/usr/locl/mysql
3. Enter the mysql directory cd/usr/local
4. You can create a user group and user for MySQL to start, close, and operate databases:
# Groupadd mysql // create a mysql Group
# Useradd-g mysql // Add a mysql user to the mysql Group
5. Users and user groups have been created, but this is not enough. To operate the database, you must have access to database-related files and directories.
Chown-R mysql. mysql.
6. scripts/mysql_install_db -- user = mysql -- datadir = data/
7. Grant the program ownership to "root" and the data directory ownership to users who can run "mysqld ".
Chown-R root.
Chown-R mysql data
9. cp support-files/my-medium.cnf/etc/my. cnf
Cp support-files/mysql. server/etc/init. d/mysql
10. ps-ef | remove mysql-related processes after grep mysqld
11. Use the mysql user to start the MySQL server. & indicates that the server is running in the background
Bin/mysqld_safe -- user = mysql &
Ii. Common Database Operations
1. the following commands can be used to connect to the MySQL server:
Mysql-h host address-u username-p Password
To connect to a local MySQL server, perform the following operations:
I. Open the terminal and enter the mysql/bin directory.
Ii. Enter the mysql-u root-p command and press enter to enter the password as prompted (here, the root user is used to log on, of course, you can also use the mysql user to log on)
Iii. If MySQL is just installed, the Super User root does not have a password, so press enter to enter. The system will display the MySQL prompt "mysql>"
2. Password Management
The database system can also manage user passwords. Users can add or modify passwords. If you have not set a password, you can add a password to the keystore. You can use the mysqladmin command with the password parameter to implement this.
Mysqladmin-u user name password New password
Mysqladmin-u username-p old password New password