首页 > 数据库技术 > 详细

MySQL数据库从入门到实战(二)

时间:2018-04-03 23:34:56      阅读:253      评论:0      收藏:0      [点我收藏+]

MySQL安装(5.6.36)(CentOS6
(1)准备工作:(关闭selinux,防火墙)
(2)开始安装

  • 1、安装依赖包(配置好yum源)*
    yum install -y ncurses-devel libaio-devel
    rpm -qa ncurses-devel libaio-devel
    vi /etc/yum.conf
    keepcache=1 将网络yum源使用过的软件包保存下来
    cachedir=/var/cache/yum/$basearch/$releasever 保存在这个位置
    2.安装cmake
    yum install cmake -y
    rpm -qa cmake
    3.设置用户
    useradd -s /sbin/nologin -M mysql
    id mysql
    4.解压安装
    cd /home/oldboy/tools/
    wget -q http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36.tar.gz
    ls -l mysql-5.6.36.tar.gz
    尽量去官方下载
    [root@server2 data]# md5sum mysql-5.6.36.tar.gz
    a36a241164c78286993cbe1079626cdd mysql-5.6.36.tar.gz
    [root@server2 data]#
    tar xf mysql-5.6.36.tar.gz
    cd mysql-5.6.36

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \
-DMYSQL_DATADIR=/application/mysql-5.6.36/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0


make && make install
ln -s /application/mysql-5.6.36/ /application/mysql
5.初始化及配置数据库
cp support-files/my*.cnf /etc/my.cnf
下面两步必做,不然初始化出错
mkdir -p /application/mysql-5.6.36/tmp
chown -R mysql.mysql /application/mysql-5.6.36/tmp

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql

chown -R mysql.mysql /application/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld

/etc/init.d/mysqld start
chkconfig mysqld on
chkconfig --list mysqld
netstat -lntup|grep 3306

echo ‘PATH=/application/mysql/bin/:$PATH‘ >>/etc/profile
source /etc/profile
mysql

设置密码:
mysqladmin -u root password ‘123456‘
mysql -uroot -poldboy123
清理用户及无用数据库(基本优化)
select user,host from mysql.user;
drop user ‘‘@‘db02‘;
drop user ‘‘@‘localhost‘;
drop user ‘root‘@‘db02‘;
drop user ‘root‘@‘::1‘;
select user,host from mysql.user;
drop database test;
show databases;


常见问题:
故障:ERROR! The server quit without updating PID file
1.权限.chown -R mysql.mysql
2.killall mysqld
3.重新初始化数据.
4.运行1年了,出问题(非法(断电)关机或者非法关数据库,例如kill -9).

MySQL数据库从入门到实战(二)

原文:http://blog.51cto.com/13520774/2094457

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!