linux安装MySQL5.6.41

安装mysql5.6.41
获取安装包

https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz

安装依赖

yum install autoconf libaio* -y

创建用户、组

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

解压

tar -zxvf mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz -C /usr/local
cd /usr/local
ln -s mysql-5.6.41-linux-glibc2.12-x86_64 mysql

初始化数据库

cd mysql/scripts
./mysql_install_db --user=mysql --datadir=/mydata/data/ --basedir=/usr/local/mysql

配置启动脚本

cp support-files/mysql.server /etc/init.d/mysqld

配置启动文件
将下面配置存放在/etc/my.cnf

[mysqld]
datadir=/mydata/data
socket=/mydata/data/mysql.sock
user=mysql
character_set_server = utf8
init_connect = 'SET NAMES utf8'
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
skip_name_resolve
innodb_file_per_table=ON
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql]
socket=/mydata/data/mysql.sock

启动

/etc/init.d/mysqld start

配置环境变量

在文件/etc/proflie文件最后添加

export PATH=$PATH:/usr/local/mysql/bin

登录

mysql

登录,修改密码

mysql
set password=password('admin');

你可能感兴趣的:(mysql)