Centos安装mysql5.6.33

下载安装包

  百度网盘地址:mysql

    连接:https://pan.baidu.com/s/15xaHIqvjggS_rFP_jL-BVA linux

    提取码:mh48
sql

上传到服务器

  mkdir mysql   #在/usr/local/目录下建立mysql文件夹数据库

  使用rz命令上传到/usr/local/mysql/目录下vim

  tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz  #解压bash

  mv mysql-5.6.33-linux-glibc2.5-x86_64 mysql   #重命名文件夹为mysql服务器

安装mysql

groupadd mysql  #建立mysql用户组
useradd -g mysql mysql  #建立mysql用户并添加到mysql用户组
cp mysql/support-files/my-default.cnf /etc/my.cnf   #建立my.cnf文件
vim /etc/my.cnf  #编辑my.cnf文件

下面是个人my.cnf文件内容
  
个人配置以下
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir =/usr/local/mysql/

datadir = /usr/local/mysql/data

log-error = /usr/local/mysql/data/error.log

pid-file = /usr/local/mysql/data/mysql.pid

user = mysql

tmpdir = /tmp
#datadir = .....
port =3306
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
cd /usr/local/mysql/  #进入mysql目录
chown -R mysql:mysql ./    #修改当前目录拥有者为mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/   #安装数据库
chown -R mysql:mysql data  #修改当前data目录的拥有者为mysql用户

配置mysql

chown 777 /etc/my.cnf  #给my.cnf最大权限
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld  #复制启动脚本到资源目录
chmod +x /etc/rc.d/init.d/mysqld  #增长mysql服务控制脚本执行权限
chkconfig --add mysqld  #将mysqld服务加到系统服务中
chkconfig --list mysqld  #检查mysqld服务是否已经生效

至此安装完成,使用 service mysqld start 启动mysql
vim ~/.bash_profile  #将mysql的bin目录加入PATH环境变量,编辑 ~/.bash_profile文件

在文件最后添加以下信息:export PATH=$PATH:/usr/local/mysql/bin

source ~/.bash_profile
#刷新一下
以后登录mysql  mysql -uroot -p,默认是没有密码的,以后修改密码为root update user set password=password('root') where user='root' and host='localhost';
 
flush privileges; #
以后容许远程链接远程链接的用户名和密码我设置为root
 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
相关文章
相关标签/搜索