下载安装包
mysql 资源包链接 提取码:efzg
上传MySQL-5.5.62-1.el7.x86_64.rpm-bundle.tar包到 /opt/software下
mkdir /opt/software
cd /opt/software
rz "MySQL-5.5.62-1.el7.x86_64.rpm-bundle.tar文件目录"
解压安装包到/opt/module/
mkdir /opt/module/
tar -zxvf MySQL-5.5.62-1.el7.x86_64.rpm-bundle.tar -C /opt/module/
卸载centos自带mysql
rpm -qa|grep -i mysql
yum -y remove maria*
rpm -qa | grep mariadb
rpm -e "查询出来的版本" --nodeps
安装配置
切换目录
cd /opt/module/ && ls
安装mysql服务端
rpm -ivh MySQL-server-5.5.62-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.5.62-1.el7.x86_64.rpm --nodeps
安装mysql 客户端
rpm -ivh MySQL-client-5.5.62-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.5.62-1.el7.x86_64.rpm --nodeps
查看mysql是否安装成功
mysqladmin --version
cat /etc/passwd|grep mysql
cat /etc/group|grep mysql
启停Mysql服务
启动mysql服务:systemctl start mysql
停止mysql服务:systemctl stop mysql
重启mysql服务:systemctl restart mysql
/usr/bin/mysql_install_db --user=mysql
设置root密码、设置成功之后再次登录需要输入正确密码
/usr/bin/mysqladmin -u root password 您的密码
mysqladmin -uroot -p'123' password 'new_password' //123为旧密码
mysql开机启动、到此MySql安装完成
systemctl enable mysql
chkconfig --list|grep mysql
chkconfig mysql on
目录介绍
名称 | 路径 | 描述 |
---|
–basedir | /usr/bin | 相关命令目录 | –datadir | /var/lib/mysql/mysql | 数据库文件的存放路径 | –plugin-dir | /usr/lib64/mysql/plugin | 插件存放路 | –log-error | /var/lib/mysql/iZ2ze9f5wnpdptfmhe7olgZ.err | 错误日志存放路径 | –pid-file | /var/lib/mysql/iZ2ze9f5wnpdptfmhe7olgZ.pid | 进程pid文件 | –socket | /var/lib/mysql/mysql.sock | 本地连接时用的unix套接字文件 | 其它 | /usr/share/mysql | mysql启停脚本配置目录 |
修改字符集
查看当前字符集、可以看到默认的服务端与客户端都使用了latin1、我们将其修改为utf8
show variables like 'character%';
拷贝/usr/share/mysql/my-huge.cnf文件到/etc/下并重命名为:my.cnf
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
编辑/etc/my.cnf 文件配置字符集信息
vim /etc/my.cnf
[client]
default-character-set=utf8
[mysqld]
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
[mysql]
default-character-set=utf8
配置MySQL远程访问
登录服务器
mysql -u root -p您的密码
选中默认的配置库
use mysql;
查询主机信息
select host, user from user;
修改主机访问权限
update user set host='%' where user='root' and host='localhost';
删除多余账户
delete from user where host!='%';
刷新缓存配置并重启MySQL
flush privileges;
exit;
quit;
systemctl restart mysql;
mysql 性能优化
编辑 /etc/my.cnf
server_id=2
log-bin=mysql-bin
binlog-format=ROW
expire_logs_days = 30
max_connections=500
innodb_buffer_pool_size = 30G
|