这里写目录标题
上传文件
scp mysql-* root@192.168.0.111:/root/
解压
tar -zxvf mysql-5.7-*.tar.gz
mv mysql-5.7-* /usr/local/mysql
cd /usr/local/mysql
创建用户和用户组
groupadd mysql
useradd -g mysql mysql
passwd mysql
chown -R mysql:mysql /usr/local/mysql
执行安装脚本
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql
启动
启动
cd /usr/local/mysql
./support-files/mysql.server start
若已启动mysql,则kill掉
ps aux|grep mysql
# kill -9 上边的进程号
# 或者下边一条命令即可杀掉所有MySQL进程
ps aux|grep mysql|awk '{print $2}'|xargs kill -9
更改mysql密码
cd /usr/local/mysql
./bin/mysqladmin -u root -h localhost.localdomain password 'root'
登录
./bin/mysql -h127.0.0.1 -uroot -proot
授权root远程登录权限
grant all privileges on *.* to root@'%' identified by 'root';
flush privileges;
将MySQL加入Service系统服务
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on service
service mysqld restart
service mysqld status
配置my.cnf
vim my.cnf
# 添加以下两条语句并保存退出
character_set_server=utf8
lower_case_table_names=1
max_allowed_packet=100M
重启mysql
systemctl status mysqld
问题:
[root@node2 ~]# mysql
-bash: mysql: command not found
/usr/local/bin目录下缺失mysql执行脚本导致,需要建立软链接:
ln -s /usr/local/mysql/bin/mysql /usr/bin