After installing the previous Ubuntu installation, starting MySQL does not start up. The error code is "the server quit without updating PID file (/var/lib/mysql/centos.pid)", baidu and Google have searched some information, basically consistent, not help me, It's not going to change as they say. So combined with Zhang Yan's blog, and finally successfully done.
First step: We first install the dependent libraries and development tools
The code is as follows |
Copy Code |
#依赖库和开发工具 Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Openldap-clients openldap-servers #Nginx Yum-y Install Pcre-devel Zlib-devel #Php Yum-y Install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel
#Mysql Yum-y Install Bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel |
Step two: Because mysql5.5 start, no longer use configure installation, but use CMake. So we need to install CMake first.
The code is as follows |
Copy Code |
wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz TAR-ZXVF cmake-2.8.6.tar.gz CD cmake-2.8.6/ ./configure Make && make install |
Step three: CMake install MySQL (i have downloaded the MySQL source file, put on a U disk, copy to/tmp directory)
The code is as follows |
Copy Code |
Enter the/tmp directory TAR-ZXVF mysql-5.5.25.tar.gz CD mysql-5.5.25 CMake -dcmake_install_prefix=/usr/local/webserver/mysql -dmysql_datadir=/user/local/webserver/mysql/data -dsysconfdir=/etc -dextra_charsets=all -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dwith_innobase_storage_engine=1 -dwith_archive_storage_engine=1 -dwith_blackhole_storage_engine=1 -dwith_federated_storage_engine=1 -dwith_partition_storage_engine=1 -dwith_perfschema_storage_engine=1 -dmysql_unix_addr=/tmp/mysqld.sock -dmysql_tcp_port=3306 -dwith_debug=0 -denabled_local_infile=1 Carriage return execution, execute make && make install after completion |
Fourth step: Set up MySQL
The code is as follows |
Copy Code |
#设置Mysql #在support-files Directory has five configuration information files (important here, be sure to copy the corresponding CNF files according to your own memory, otherwise MySQL will never come): #my-small.cnf (Memory <=64m) #my-medium.cnf (Memory 128M) #my-large.cnf (Memory 512M) #my-huge.cnf (Memory 1g-2g) #my-innodb-heavy-4g.cnf (Memory 4GB) Cd/usr/local/webserver/mysql CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF Vi/etc/my.cnf #在 [MYSQLD] paragraph increased DataDir =/data/mysql Wait-timeout = 30 Max_connections = 512 Default-storage-engine = MyISAM #在 [MYSQLD] paragraph modification Max_allowed_packet = 16M |
Fifth step: Add MySQL Users and user groups, generate a new MySQL authorization table
The code is as follows |
Copy Code |
Add users and user groups running MySQL Groupadd MySQL useradd-g MySQL mysql-s/bin/false-d/home/mysql//No shell, not native landing (safe) Cd/usr/local/webserver/mysql Chown-r Root. Chown-r MySQL Data Chgrp-r MySQL. Generate a new MySQL authorization form Access to the directory of MySQL installation directory Cd/usr/local/webserver/mysql/scripts Generate a new MySQL authorization form using the mysql_install_db script ./mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/usr/local/webserver/mysql/data--user=mysql MySQL Server service item settings in the system Copy Service files and modify Cd/usr/local/webserver/mysql/support-files CP Mysql.server MYSQLD Modify Mysqld Basedir=/usr/local/webserver/mysql Datadir=/usr/local/webserver/mysql/data MV Mysqld/etc/init.d/mysqld chmod 755/etc/init.d/mysqld Set up a soft connection to make MySQL, mysqldump, mysqladmin these three bin commands can be run directly in the shell sudo ln-s/usr/local/webserver/mysql/bin/mysql/usr/bin sudo ln-s/usr/local/webserver/mysql/bin/mysqldump/usr/bin sudo ln-s/usr/local/webserver/mysql/bin/mysqladmin/usr/bin |
RM-RF/ETC/MYSQL/MY.CNF because the file has been copied to/etc/my.cnf if not deleted, MySQL does not start up.
Sixth step: Start MySQL, set MySQL user name and password
code is as follows |
copy code |
/etc/ Init.d/mysqld start //Set root password mysqladmin-u root password "admin" //mysql database Chinese garbled resolution VI/ETC/MY.CNF //Then add Character-set-server=utf8 //Then go to MySQL under [mysqld] configuration options cd/usr/local/webserver/mysql/ The bin Mysql-u root-p Prompts for a password mysql> show variables like '%character% '; /Result: Character_set_database,char Acter_set_server two entries have changed to UTF8 |