当前位置:Gxlcms > 数据库问题 > mysql 5.5.58 tar包安装部署

mysql 5.5.58 tar包安装部署

时间:2021-07-01 10:21:17 帮助过:5人阅读

-g mysql -m -s "/bin/bash" -b /home/mysql -d /home/mysql mysql

修改mysql 系统用户的密码

passwd mysql

将下载好的tar 包解压到 /opt 目录下

tar -zxvf mysql-5.5.58-linux-glibc2.12-x86_64.tar.gz -C /opt

修改mysql 软件的权限

chown mysql:mysql -R /opt/mysql-5.5.58-linux-glibc2.12-x86_64

修改 /etc/my.cnf 配置文件(由于在centos 7.4 版本中,默认是已经配置了mariadb ,所以修改配置文件前,有需要的话,可以对原文件进行备份)

[mysql]
default-character-set = utf8

[mysqld]
skip-name-resolve
port = 3306
basedir = /opt/mysql-5.5.58-linux-glibc2.12-x86_64
datadir = /opt/mysql-5.5.58-linux-glibc2.12-x86_64/data
socket = /tmp/mysql.sock
max_connections = 200
character-set-server = utf8
default-storage-engine = INNODB
lower_case_table_names = 1
max_allowed_packet = 16M
log-bin = /opt/mysql-5.5.58-linux-glibc2.12-x86_64/binlog/replicalog
server-id = 1
binlog_format = row

[mysqld_safe]
log-error = /opt/mysql-5.5.58-linux-glibc2.12-x86_64/log/mysql.log
pid-file = /opt/mysql-5.5.58-linux-glibc2.12-x86_64/log/mysql.pid

 

这里有必要对几个参数进行说明。

log-bin 参数是显时设置mysql 事务日志归档目录的参数,指定的目录下将来会生成会若干个归档事务日志文件,并且会生成一个名为 binlog.index 的索引文件

binlog_foramt 参数是指定 归档事务日志的格式,因为作者的mysql 服务未来要作为 OGG 的源端进行部署,所以归档事务日志必须要设置为 row

切换mysql 系统用户

su - mysql
cd /opt/mysql-5.5.58-linux-glibc2.12-x86_64

使用mysql 系统用户新建目录

mkdir -p /opt/mysql-5.5.58-linux-glibc2.12-x86_64/binlog
mkdir -p /opt/mysql-5.5.58-linux-glibc2.12-x86_64/log
mkdir -p /opt/mysql-5.5.58-linux-glibc2.12-x86_64/data

初始化mysql 的相关数据文件

scripts/mysql_install_db --user=mysql --basedir=/opt/mysql-5.5.58-linux-glibc2.12-x86_64 --datadir=/opt/mysql-5.5.58-linux-glibc2.12-x86_64/data

使用安全模式启动mysql 服务,这个操作执行后控制台会停住,需要用户在另外一个shell 窗口中继续操作

bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking --basedir=/opt/mysql-5.5.58-linux-glibc2.12-x86_64 --datadir=/opt/mysql-5.5.58-linux-glibc2.12-x86_64/data

进行mysql shell 控制台,然后设置root 用户的密码

bin/mysql -uroot
mysql> update mysql.user set authentication_string=PASSWORD(mysql) where user=root;

在shell 中ps 找到 刚才启动的mysql 服务,然后停止它

kill -15 $(ps -ef |grep "mysqld --basedir" | grep -v grep | awk -F   {print $2})

后面的操作使用root 系统用户继续操作

将mysql 的service 脚本拷贝到 /etc/init.d 目录

cp /opt/mysql-5.5.58-linux-glibc2.12-x86_64/support-files/mysql.server /etc/init.d/

使用root 用户启动 mysql服务

service mysqld start
  • 查看mysql 服务的状态
service mysqld status
  • 停止mysql 服务的命令
service mysqld stop

在mysql 服务启动状态下,进入mysql shell 控制台,再次设置root 密码

bin/mysql -uroot
mysql> set password= password(mysql);

这样mysql 服务的部署基本就完成了。

 

mysql 5.5.58 tar包安装部署

标签:索引   replica   指定   mkdir   cat   down   cal   use   ati   

人气教程排行