一、编译安装
tar -zxf mysql-5.5.32-linux2.6-x86_64.tar.gz mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5 cd /application/mysql-5.5/ ls chown -R mysql.mysql data ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql-5.5/ --datadir=/application/mysql-5.5/data/ 启动配置文件 [root@server support-files]# cp my-small.cnf /etc/my.cnf [root@server support-files]# cp mysql.server /etc/init.d/mysqld
二、数据库优化
对数据库用户表的优化 mysql> select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | localhost | +------+-----------+ 2 rows in set (0.00 sec) 例子: mysql> drop user 'root'@'server';
三、遇到的问题
问题1、
/application/mysql-5.5//bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 解决 [root@server mysql-5.5]# yum install -y libaio
问题2、由于之前安装的是源码包,版本低,现在升级安装的是二进制的包,在初始化数据库的时候出现这个问题
170903 20:12:10 [ERROR] /application/mysql-5.5//bin/mysqld: unknown option '--skip-locking' 170903 20:12:10 [ERROR] Aborting 170903 20:12:10 [Note] /application/mysql-5.5//bin/mysqld: Shutdown complete 解决 就把mysql默认的my.cnf文件中的skip-locking参数去掉 [mysqld] #skip-locking
问题3、
[root@server support-files]# /etc/init.d/mysqld start /etc/init.d/mysqld: line 256: my_print_defaults: command not found /etc/init.d/mysqld: line 276: cd: /usr/local/mysql: No such file or directory Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe) 解决 编辑/etc/my.cnf 文件,因为缺少basedir 和 datadir 两个路径,在 [mysqld] 添加上即可 #vim /etc/my.cnf [mysqld] ........... ........... basedir=/usr/local/mysql datadir=/usr/local/mysql/data 这个添加在这个模块的最后 保存退出,然后重新启动就可以
问题4、
有时候初始化正常,服务正常启动,但是还是进不了数据库,如果此时不是yum/rpm安装的可以尝试一下在/data目录删除所有数据,然后重新初始化,然后进入数据库试试