Install MySQL5.5 in RPM mode in CentOS
First go to the mySQL official website to download the page:
Http://dev.mysql.com/downloads/mysql/#downloads
Select Platform Select Oracle & Red Hat Linux 4 & 5
Download the following three files respectively (because my machine is 32-bit, the following is a 32-bit package. If your machine is 64-bit, please download the 64-bit version ):
1. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
MySQL Server
2. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Client Utilities
3. Red Hat & Oracle Linux 5 (x86, 32-bit), RPM Package
Development Libraries
Use the wget command to download the three files through breakpoint transmission.
[Plain] view plaincopy
- Wget-chttp: // cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.28-1.rhel5.i386.rpm
- Wget-chttp: // cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.28-1.rhel5.i386.rpm
- Wget-chttp: // cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.28-1.rhel5.i386.rpm
After the download is complete, start the installation:
rpm -ivh MySQL-server-5.5.28-1.rhel5.i386.rpm
rpm -ivh MySQL-client-5.5.28-1.rhel5.i386.rpm
rpm -ivh MySQL-devel-5.5.28-1.rhel5.i386.rpmIf an error occurs during installation:
[Plain] view plaincopy
- Error: Faileddependencies:
- Libaio. so.1 () (64bit) isneededbyMySQL-server-5.5.28-1.rhel5.x86_64
- Libaio. so.1 (LIBAIO_0.1) (64bit) isneededbyMySQL-server-5.5.28-1.rhel5.x86_64
- Libaio. so.1 (LIBAIO_0.4) (64bit) isneededbyMySQL-server-5.5.28-1.rhel5.x86_64
The dependency library is missing. Install the dependency library.
[Plain] view plaincopy
- Yuminstalllibaio
After the installation is complete, enter mysql to check whether the installation is successful [plain] view plaincopy
- Mysql
If there is no response or the following error message is displayed:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)
The mysql service has not been started. Enter service mysql start to start the mysql service.
[Plain] view plaincopy
- Servicemysqlstart
Then enter mysql. If the following message is displayed, it indicates that the operation is successful.
[Plain] view plaincopy
- WelcometotheMySQLmonitor. Commandsendwith; or \ g.
- YourMySQLconnectionidis1
- Serverversion: 5.5.16MySQLCommunityServer (GPL)
- Copyright (c) 2000,2011, Oracleand/oritsaffiliates. Allrightsreserved.
- Oracleisaregisteredtrademarkoforacleconfigurationand/orits
- Affiliates. Othernamesmaybetrademarksoftheirrespective
- Owners.
- Type 'help; 'or' \ H' forhelp. Type '\ C' toclearthur ecurrentinputstatement.
If an error occurs
[Plain] view plaincopy
- StartingMySQL... ERROR! TheserverquitwithoutupdatingPIDfile (/var/lib/mysql/lechiexxxxx. pid ).
View log files based on the error address
The address here is/var/lib/mysql/
The log name is generally the server name. err
The following message is displayed:
[Plain] view plaincopy
- [ERROR] Fatalerror: Can 'topenandlockprivilegetables: Table 'mysql. host' doesn' texist
- 12101215: 12: 05mysqld_safemysqldfrompidfile/var/lib/mysql/lechiexxxxxx. pidended
Therefore, the table is missing.
Execute table Initialization
[Plain] view plaincopy
- /Usr/bin/mysql_install_db
Start or fail later. view the log:
[Plain] view plaincopy
- [ERROR] Failedtoopenlog (file './mysql-bin.000004', errno13)
You probably do not have permission to grant mysql permission.
[Plain] view plaincopy
- Chown-Rmysql: mysql/var/lib/mysql/
Then run service mysql start again to start the service, success!
Enable daemon
[Plain] view plaincopy
- /Usr/bin/mysqld_safe &
I usually press enter several times to exit putty or secureCRT, and then re-open a session.
[Problem]
Where can I install mysql after installation? Usually in the following folder
/Usr/share/mysql/or/usr/lib/mysql/or/var/lib/mysql/
You can run the following command:
[Plain] view plaincopy
- Whereismysql
To check where the installation is. [Initialization settings]
MySQL installed in the rpm package does not install/etc/my. cnf file, solution, just need to copy the my-huge.cnf file under the/usr/share/mysql directory to the/etc directory, and renamed my. cnf
[Plain] view plaincopy
- Cp/usr/share/mysql/my-huge.cnf/etc/my. cnf
Set Password]
The default password for the first installation is null. You can use the following command to change the root password,
[Plain] view plaincopy
- /Usr/bin/mysqladmin-urootpassword new password XXXXX
Example:/usr/bin/mysqladmin-u root password 123456
Then log on again
[Plain] view plaincopy
- Mysql-uroot-p new password XXXXX
Change logon Password
You can use the mysqladmin command to change the password or the database to change the password.
[Directory description] 1. Database directory
/Var/lib/mysql/
2. Configuration File
/Usr/share/mysql (mysql. server command and configuration file)
3. Related commands
/Usr/bin (commands such as mysqladmin mysqldump)
4. Start the script
/Etc/rc. d/init. d/(directory for starting the script file mysql)
[Start and Stop] 1. Start
After MySQL is installed, run the following command to start mysql in the/etc/init. d directory.
/Etc/init. d/mysql start
Or
/Etc/rc. d/init. d/mysql start
2. Stop
/Usr/bin/mysqladmin-u root-p shutdown
3. Automatic Start
1) Check whether mysql is in the Auto Start List
/Sbin/chkconfig-list
2) Add MySQL to the startup Service Group of your system.
/Sbin/chkconfig-add mysql
3) Delete MySQL from the startup Service Group.
/Sbin/chkconfig-del mysql
[Change MySQL Directory]
The default data file storage directory of MySQL is/var/lib/mysql.
To move the directory to/home/data, perform the following steps:
1. Create a data directory under the home Directory
Cd/home
Mkdir data
Remember to grant permissions:
Chown-R mysql: mysql/home/data
2. Stop the MySQL service process:
Mysqladmin-u root-p shutdown
3. Move the entire/var/lib/mysql directory to/home/data
Mv/var/lib/mysql/home/data/
In this way, the MySQL data file is moved to/home/data/mysql.
4. Find the my. cnf configuration file.
If the my. cnf configuration file does not exist in the/etc/directory, go to/usr/share/mysql/and find the *. cnf file,
Copy one of them to/etc/and change it to my. cnf. The command is as follows:
Cp/usr/share/mysql/my-medium.cnf/etc/my. cnf
5. Edit the MySQL configuration file/etc/my. cnf.
To ensure that MySQL works properly, you must specify the location where the mysql. sock file is generated.
Modify the value on the right of a socket =/var/lib/mysql. sock line with a moderate number
Is/home/mysql. sock. The procedure is as follows:
Vi my. cnf # Use the vi tool to edit the my. cnf file and find the following data to modify:
# The MySQL server
[Mysqld]
Port = 3306
# Socket =/var/lib/mysql. sock # original content. To be more secure, use "#" to comment this line
Socket =/home/data/mysql. sock # Add this line
6. Modify the MySQL STARTUP script/etc/rc. d/init. d/mysql
Finally, you need to modify the MySQL STARTUP script/etc/rc. d/init. d/mysql: Replace the path on the right of the equal sign in a row of datadir =/var/lib/mysql with your actual storage
Path: home/data/mysql.
Vi/etc/rc. d/init. d/mysql
# Datadir =/var/lib/mysql # comment on this line
Datadir =/home/data/mysql # Add this row
7. Restart the MySQL service.
/Etc/rc. d/init. d/mysql start
Or use the reboot command to restart Linux.
If it works properly, it will succeed. Otherwise, check again against the previous seven steps.
Configure Remote Access]
For security reasons, Mysql does not allow remote access by default. You can use the following to enable remote access:
// Grant data access permissions to any host
Mysql> grant all privileges on *. * TO 'root' @ '%' WITH GRANT OPTION
// Make the modification take effect
Mysql> FLUSH PRIVILEGES
If remote access is still not available, it is likely the cause of the firewall. You can enable port 3306 in the firewall or simply turn off the firewall.