This article describes MySQL - a detailed introduction to the installation of MySQL5.5 in RPM mode under CentOS. It has reference value. Let’s analyze it together.
http: //dev.mysql.com/downloads/mysql/#downloads
Select Platform Select Oracle & Red Hat Linux 4 & 5
to download the following three files respectively ( Since my machine is 32-bit, the following is the 32-bit version of the 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 PackageDevelopment Libraries
wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.28-1.rhel5.i386.rpm wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.28-1.rhel5.i386.rpm wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.28-1.rhel5.i386.rpmAfter 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
If an error occurs during the installation:
error: Failed dependencies: libaio.so.1()(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.28-1.rhel5.x86_64
yum install libaio
mysql
If there is no response or the following error message appears:
Indicates that the mysql service has not been started yet, enter service mysql start Start the mysql service
service mysql start
and then enter mysql. If the following prompt message appears, it means success.
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.16 MySQL Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Starting MySQL.... ERROR! The server quit without updating PID file (/var/lib/mysql/lechiexxxxx.pid).
View the log file based on the error address
The address here is /var/lib/mysql/
The log name is generally the server name.err
When I open it, I find this sentence:
[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 121012 15:12:05 mysqld_safe mysqld from pid file /var/lib/mysql/lechiexxxxxx.pid ended
So the table is missing.
Initialization of the execution table
/usr/bin/mysql_install_db
After execution, the startup still fails. Check the log:
[ERROR] Failed to open log (file './mysql-bin.000004', errno 13)
It should be that there is no permission. After granting mysql permission
chown -R mysql:mysql /var/lib/mysql/
Re-execute service mysql start to start the service, success!
You can start the daemon process
/usr/bin/mysqld_safe &
I usually press Enter several times to exit putty or secureCRT, and then reopen a session
[Question]
/usr/share/mysql/ or /usr/lib/mysql/ or /var/lib/mysql/
You can pass the command:
whereis mysql
Let’s see where it is installed.
[Initialization Settings]
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
[Set password]
/usr/bin/mysqladmin -u root password 新密码XXXXX
For example: /usr/bin/mysqladmin -u root password 123456
Then log in again
mysql -u root –p新密码XXXXX
Modify the login password
This is through The mysqladmin command can be used to modify the password, or the password can be changed by modifying the library.
[Directory Description]
2. Configuration file
3. Related commands
4. Startup script
[Start and Stop]
/etc/init.d/mysql start
or
/etc/rc.d/init.d/mysql start
2. Stop
3. Automatically start
/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]
If you want to move the directory to /home/data, you need to perform the following steps:
1. Create the data directory under the home directory
mkdir data
Remember to grant permissions:
chown -R mysql:mysql /home/data
2. Stop the MySQL service process :
3. Move the entire /var/lib/mysql directory to /home/data
This will move the MySQL data file to /home/data/mysql
4. Find the my.cnf configuration file
copy one of them to /etc/ and rename it to my.cnf). The command is as follows:
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。
修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值
为:/home/mysql/mysql.sock 。操作如下:
vi my.cnf ##用vi工具编辑my.cnf文件,找到下列数据修改之 # The MySQL server [mysqld] port = 3306 #socket = /var/lib/mysql/mysql.sock ##原内容,为了更稳妥用“#”注释此行 socket = /home/data/mysql/mysql.sock #加上此行
最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存
放路径:home/data/mysql。
vi /etc/rc.d/init.d/mysql #datadir=/var/lib/mysql##注释此行 datadir=/home/data/mysql ##加上此行
/etc/rc.d/init.d/mysql start
或用reboot命令重启Linux
如果工作正常移动就成功了,否则对照前面的7步再检查一下。
处于安全考虑,Mysql默认是不允许远程访问的,可以使用下面开启远程访问
//赋予任何主机访问数据的权限mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION //使修改生效mysql>FLUSH PRIVILEGES
如果依然不能远程访问的话,那就很可能防火墙的原因了,可以在防火墙中开启3306端口或者干脆关掉防火墙。
The above is the detailed content of MySQL - Detailed introduction to installing MySQL5.5 in RPM mode under CentOS. For more information, please follow other related articles on the PHP Chinese website!