在linux(Centos 7以上版本亲测)上安装mysql5.6

Mysql的安装:

1.登录服务器,依次输入以下命令进行安装
cd /usr/local
2.下载安装包并解压
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
2.1.添加用户组
groupadd mysql
2.2.添加用户mysql 到用户组mysql
useradd -g mysql mysql
2.3安装
cd /usr/local/mysql/

mkdir ./data/mysql

chown -R mysql:mysql ./

./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
如果执行报错
[root@dc1atmpapp12 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
解决方法是安装autoconf库
执行命令:yum -y install autoconf
正确执行上面命令以后
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
2.4.修改启动脚本
vi /etc/init.d/mysqld
2.4.1修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
2.5.启动服务
service mysqld start
2.6加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql//bin
source /etc/profile
2.7.测试连接
./mysql/bin/mysql -uroot
2.8.启动mysql
service mysqld start
service mysqld status
2.9.创建用户修改root密码并授权
Mysql -uroot -p
set password=password('root');
FLUSH PRIVILEGES;
grant all privileges on *.* to root@"%" identified by 'root' with grant option;
FLUSH PRIVILEGES;

请顺序执行,食用更加

你可能感兴趣的:(mysql数据库,mysql5.6,数据库,mysql修改密码并赋权限)