linux mysql 安装
卸除
1,原有mysql组件
find / -name mysql 删除相关文件
2,确认是否有mysql的rpm安装包
rpm -qa | grep -i mysql
如果有就删除
yum -y remove mysql-libs*
安装
1,上传rpm文件
MySQL-server-5.6.31-1.linux_glibc2.5.x86_64.rpm
MySQL-devel-5.6.31-1.linux_glibc2.5.x86_64.rpm
MySQL-client-5.6.31-1.linux_glibc2.5.x86_64.rpm
2,安装rpm
rpm -ivh MySQL-server-5.6.31-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.31-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-client-5.6.31-1.linux_glibc2.5.x86_64.rpm
3,将MySQL的配置文件拷贝到/etc目录下。
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
4,初始化MySQL及设置密码。
/usr/bin/mysql_install_db #初始化
MySQL service mysql start #启动
MySQL cat /root/.mysql_secret #查看root账号的初始密码,会出现下述所示信息
mysql -u root -ppassword #连接数据库
set password=password(‘root‘); #设置密码
5,设置开机启动
chkconfig mysql on #添加开机启动
[[email protected]_32_234_centos storage]# chkconfig --list | grep mysql mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6,修改/etc/my.cnf
[mysqld] datadir = /data/sinodata/pushserver/mysql/data
port = 6622
7,复制文件 /var/lib/mysql/ 到 /data/sinodata/pushserver/mysql/data
cp -r /var/lib/mysql/* /data/sinodata/pushserver/mysql/data
8,赋予/data/sinodata/pushserver/mysql/data 文件夹权限
9,# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
10,数据库的文件就在/data/sinodata/pushserver/mysql/data中,端口号为6622
chmod -R 777 /data/sinodata/pushserver/mysql/data
远程连接问题
本地连接后,对用户进行授权
mysql>grant all privileges on *.* to ‘userName‘@‘%‘ identified by ‘userPassword‘ with grant option;
mysql>flush privileges;