下载tar包MySQL-5.6.26-1.el6.i686.rpm-bundle.tar:
# wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-5.6.26-1.el6.i686.rpm-bundle.tar(注意el6是指linux6)
解压tar包:# tar xf MySQL-5.6.26-1.el6.i686.rpm-bundle.tar
安装之前先执行:rpm -e --nodeps mysql-libs-5.1.*(排除预安装mysql引起的冲突)
安装server包:# rpm -ivh MySQL-server--5.6.26-1.el6.i686.rpm
安装client包:# rpm -ivh MySQL-client--5.6.26-1.el6.i686.rpm
安装devel包:# rpm -ivh MySQL-devel--5.6.26-1.el6.i686.rpm
修改配置文件位置:# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
启动服务:service mysql start
配置远程访问:
//赋予任何主机访问数据的权限(mypassword为加密后的密码)
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD 'mypassword' WITH GRANT OPTION
//使修改生效
mysql>FLUSH PRIVILEGES
设置MySQL服务开机自启动:# chkconfig mysql on
# chkconfig mysql --list mysql
注:
1、ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
说明mysql服务还没有启动,输入service mysql start启动mysql服务
2、ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
密码在/root/.mysql_secret里面,找出来,修改密码,再重新登录。具体操作步骤如下:
# /etc/rc.d/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &(--skip-grant-tables:不启动grant-tables(授权表),跳过权限控制;--skip-networking :跳过TCP/IP协议,只在本机访问(从网上有些资料看,这个选项不是必须的。可以不用))
# mysql -u root mysql
mysql> update user set password=PASSWORD('p12#456')
-> where user='root' and host='root' or host='localhost';
mysql> flush privileges;
mysql>quit
#mysql -u root -p
3、 ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
在重置一次密码:mysql>set password = password('pass1234');
4、添加用户
GRANT USAGE ON *.* TO 'sun'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;