mysql安装

Posted doublexi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql安装相关的知识,希望对你有一定的参考价值。

一. 安装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安装的主要内容,如果未能解决你的问题,请参考以下文章

从mysql的片段中加载ListView

连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段

使用 json rereiver php mysql 在片段中填充列表视图

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

PHP代码-psysh调试代码片段工具

关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4Unknown system variable ‘query_cache_size(代码片段