码迷,mamicode.com
首页 > 数据库 > 详细

mysql安装

时间:2018-04-09 18:55:20      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:oca   lib   default   nod   init.d   glib   安装mysql   xpl   create   

一. 安装mysql5.6

1、下载mysql5.6免安装版本

# cd /root
# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz

2、解压mysql5.6到/usr/local/mysql5.6

# mkdir -p /usr/local/mysql5.6
# mkdir -p /data/mysql5.6
# tar xf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
# mv mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql5.6

3、创建mysql用户

# groupadd mysql 
# useradd -r -g mysql mysql
# chown -R mysql:mysql /usr/local/mysql5.6
# chown -R mysql:mysql /data/mysql5.6

4、初始化mysql

# /usr/local/mysql5.6/scripts/mysql_install_db --user=mysql --datadir=/data/mysql5.6/ --basedir=/usr/local/mysql5.6/

5、修改配置文件

# cat /usr/local/mysql5.6/my.cnf

[mysqld]
 basedir = /usr/local/mysql5.6/
 datadir = /data/mysql5.6/
 port = 3307
 socket = /data/mysql5.6/mysql.sock
 innodb_file_per_table=1
 default-storage-engine=INNODB
 explicit_defaults_for_timestamp=true
 symbolic-links=0
 max_connections=1000

[mysqld_safe]
log-error=/data/mysql5.6/mysqld.log
pid-file=/data/mysql5.6/mysqld.pid

# mv /etc/my.cnf /etc/my.cnfbak
# cp /usr/local/mysql5.6/my.cnf /etc/my.cnf
# vim /etc/profile
export MYSQL_HOME="/usr/local/mysql5.6/"
export PATH="$PATH:$MYSQL_HOME/bin"

# source /etc/profile

6、开启mysql进程

法一、
# cp /usr/local/mysql5.6/support-files/mysql.server /etc/init.d/mysql5.6
# chkconfig --add mysql5.6
# chkconfig mysql5.6 on
# service mysql5.6 start
法二、
# /usr/local/mysql5.6/bin/mysqld_safe --user=mysql  --defaults-file=/usr/local/mysql5.6/my.cnf --datadir=/data/mysql5.6/ --basedir=/usr/local/mysql5.6/  &

7、新建远程用户并修改密码

# ln -s /data/mysql5.6/mysql.sock /tmp/mysql.sock
# /usr/local/mysql5.6/bin/mysql -uroot -P3307
mysql> CREATE USER ‘root‘@‘%‘ IDENTIFIED BY ‘password‘;
mysql> GRANT ALL PRIVILEGES ON *.* TO‘root‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
mysql> update mysql.user set password=password(‘password‘) where User="root" and Host="localhost";
mysql> update mysql.user set password=password(‘password‘) where User="root" and Host="127.0.0.1";
mysql> update mysql.user set password=password(‘password‘) where User="root" and Host="hostname";
mysql> update mysql.user set password=password(‘password‘) where User="root" and Host="::1";
mysql> flush privileges;

mysql安装

标签:oca   lib   default   nod   init.d   glib   安装mysql   xpl   create   

原文地址:https://www.cnblogs.com/doublexi/p/8761027.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!