背景:现有mysql版本为5.5.40,考虑到以后需做主从,而5.6在主从方面、mysql读写方面都有很大提
环境:centos6.5 X86_64
安装目录:/database/mysql
解压目录:/database/mysql-5-6-24
数据存放目录:/database/sqldata
http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz 源代码下载
1、安装依赖包
yum install gcc gcc-c++ -y
yum install -y ncurses-devel
yum install -y openssl-devel(不安装会报错,见后文)
yum install -y cmake
yum install -y libaio
yum install -y bison
2、创建mysql用户用户组
groupadd mysql
useradd -g mysql mysql
3、cmake编译
tar –zxvf mysql-5.6.24.tar.gz
cd mysql-5-6-24
cmake \ -DCMAKE_INSTALL_PREFIX:PATH=/database/mysql \ -DMYSQL_DATADIR:PATH=/database/sqldata \ -DEXTRA_CHARSETS=all \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DMYSQL_USER=mysql \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_SSL=yes 报错:
CMake Error at cmake/ssl.cmake:83 (MESSAGE): Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support Call Stack (most recent call first): CMakeLists.txt:255 (MYSQL_CHECK_SSL) 解决:安装openssl-devel,然后rm CMakeCache.txt。重新运行以上命令。
make && make install
次步时间比较长。
#添加PATH echo "PATH=$PATH:/database/mysql/bin" >> /etc/profile source /etc/profile
#修改目录权限 chown -R mysql:mysql /database/mysql chown -R mysql:mysql /database/sqldata #拷贝配置文件 cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#设置my.conf 在[mysqld]中设置 datadir=/database/sqldata #初始化 ./scripts/mysql_install_db --user=mysql --datadir=/database/sqldata --basedir=/database/mysql 我的系统由于是最小化安装,在初始化时会出错,注意一下: [root@zabbix-server scripts]# ./mysql_install_db --user=mysql --datadir=/database/sqldata --basedir=/database/mysql -bash: /mysql_install_db: 没有那个文件或目录 [root@zabbix-server scripts]# 此时安装如下程序,再次运行初始化命令 [root@zabbix-server scripts]# yum -y install perl perl-devel 已加载插件:fastestmirror 日志: 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: /db1/mysql/bin/mysqladmin -u root password 'new-password' /db1/mysql/bin/mysqladmin -u root -h shekou password 'new-password' Alternatively you can run: /db1/mysql/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 . ; /db1/mysql/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 at http://bugs.mysql.com/ The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com WARNING: Found existing config file /db1/mysql/my.cnf on the system. Because this file might be in use, it was not replaced, but was used in bootstrap (unless you used --defaults-file) and when you later start the server. The new default config file was created as /db1/mysql/my-new.cnf, please compare it with your file and take the changes you need.
#设置mysql服务 cp /database/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld chkconfig --add mysqld service mysqld start
#空密码登陆mysql mysql
一、初始化设置密码
[root@localhost mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@localhost mysql]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 2537
[root@localhost mysql]# 170122 10:47:09 mysqld_safe Logging to '/database/sqldata/localhost.localdomain.err'.
170122 10:47:09 mysqld_safe Starting mysqld daemon with databases from /database/sqldata
[root@localhost mysql]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.15 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.
mysql> use mysql;
Database changed
mysql> UPDATE user SET Password=PASSWORD('zabbix')where USER='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@localhost mysql]# /etc/init
init/ init.d/
[root@localhost mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.170122 10:49:18 mysqld_safe mysqld from pid file /database/sqldata/localhost.localdomain.pid ended
SUCCESS!
Starting MySQL. SUCCESS!
[1]+ Done mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@localhost mysql]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.15 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.
mysql>
mysql>
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
mysql> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
转载于:https://blog.51cto.com/study2008/1788649