linux 安装 mysql
Linux rpm安装MySQL
1:查看操作系统信息
##uname -a
:
准备软件包:
MySQL-server-5.6.19-1.rhel5.x86_64.rpm
MySQL-devel-5.6.19-1.rhel5.x86_64.rpm
MySQL-client-5.6.19-1.rhel5.x86_64.rpm
下载地址:http://dev.mysql.com/downloads/mysql/
MySQL-server-5.6.19-1.rhel5.x86_64.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.19-1.rhel5.x86_64.rpm
MySQL-devel-5.6.19-1.rhel5.x86_64.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.19-1.rhel5.x86_64.rpm
MySQL-client-5.6.19-1.rhel5.x86_64.rpm
http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.19-1.rhel5.x86_64.rpm
2:安装服务端:
#rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpm
错误原因:包冲突了
#yum -y remove mysql-libs-5.1*
重新安装即可:
# rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpm
3:安装客户端
3:尝试启动服务
# /etc/init.d/mysql start
# /etc/init.d/mysql restart 重启
4:停止服务 # /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
重新执行:
Mysql>SET PASSWORD = PASSWORD('123456');
5.设置开机启动
chkconfig mysql on
[root@VM_32_234_centos storage]# chkconfig mysql on
[root@VM_32_234_centos storage]# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6.linux下设置mysql编码
linux下设置mysql编码
首先查找MySql的cnf文件的位置:
[root@flyHome gaoxiang]# find / -iname '*.cnf' -print
/etc/pki/tls/openssl.cnf
/etc/my.cnf
/usr/share/openvpn/easy-rsa/2.0/openssl-0.9.6.cnf
/usr/share/openvpn/easy-rsa/2.0/openssl.cnf
/usr/share/openvpn/easy-rsa/1.0/openssl.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/doc/mysql-server-5.5.18/my-small.cnf
/usr/share/doc/mysql-server-5.5.18/my-large.cnf
/usr/share/doc/mysql-server-5.5.18/my-innodb-heavy-4G.cnf
/usr/share/doc/mysql-server-5.5.18/my-huge.cnf
/usr/share/doc/mysql-server-5.5.18/my-medium.cnf
然后拷贝my-small.cnf、my-medium.cnf、my-huge.cnf、my-innodb-heavy-4G.cnf 其中一个到 /etc/my.cnf 下
[root@flyHome gaoxiang]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
再修改my.cnf
[root@flyHome gaoxiang]# vi /etc/my.cnf
在[client]下添加
character_set_server = utf8
在[mysqld]下添加
collation_server = utf8_general_ci
character_set_server = utf8
保存退出后重启mysqld:
[root@flyHome gaoxiang]#service mysqld restart