MYSQL 源码编译安装
1. 准备安装包: [root@localhost ~]# ls cmake-2.8.10.2.tar.gz mysql-5.5.30.tar.gz 2. 安装CMAKE: tar -xzvf cmake-2.8.10.2.tar.gz cd cmake-2.8.10.2 ./configure make make install 3. 安装MYSQL yum install ncurses-devel groupadd mysql useradd -r -g mysql mysql mkdir -p /u01/mysql/data mkdir -p /u01/mysql/logs/mysql mkdir -p /u01/mysql/data/log tar -xzvf mysql-5.5.30.tar.gz cmake -DCMAKE_INSTALL_PREFIX=/u01/mysql -DMYSQL_DATADIR=/u01/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 make make install cd /u01 chown -R root:mysql mysql chown -R mysql:mysql mysql cd mysql cp support-files/my-medium.cnf /etc/my.cnf 4. 初始化DB: [root@localhost mysql]# scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql Installing MySQL system tables... 140425 12:08:57 mysqld_safe mysqld from pid file /u01/mysql/data/localhost.localdomain.pid ended OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: ./bin/mysqladmin -u root password 'new-password' ./bin/mysqladmin -u root -h 127.0.0.1 password 'new-password' Alternatively you can run: ./bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd . ; ./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd ./mysql-test ; perl mysql-test-run.pl Please report any problems with the ./bin/mysqlbug script! [1]+ Done ./mysqld_safe (wd: /u01/mysql/bin) 5. 修改ROOT密码: [root@localhost ~]# mysqld_safe --defaults-file=/etc/my.cnf & 140426 12:12:43 mysqld_safe Logging to '/u01/mysql/logs/mysql/error3306.log'. 140426 12:12:44 mysqld_safe Starting mysqld daemon with databases from /u01/mysql/data [root@localhost ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.30-log Source distribution Copyright (c) 2000, 2013, 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. root@localhost : (none) 12:12:29> use mysql; Database changed root@localhost : mysql 12:12:45> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456"; Query OK, 0 rows affected (0.00 sec) root@localhost : mysql 12:12:47> update user set password = password('123456') where user='root'; Query OK, 4 rows affected (0.01 sec) Rows matched: 5 Changed: 4 Warnings: 0 root@localhost : mysql 12:12:55> commit; Query OK, 0 rows affected (0.00 sec) root@localhost : mysql 12:13:01> flush privileges; Query OK, 0 rows affected (0.00 sec) 第一次登录是不需要密码的。 尝试用新密码登录: [root@localhost ~]# mysql -uroot -p -S /tmp/mysql3306.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.5.30-log Source distribution Copyright (c) 2000, 2013, 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. root@localhost : (none) 12:13:41>