到oracle去下载
或在这里下载(我共享的百度云盘的文件):http://27.155.72.130/d7.baidupcs.com/file/4bfeb22f2f876825db70d9820d164343?bkt=p3-14004bfeb22f2f876825db70d9820d164343a6bde64f000002249238&xcode=c8445448be82a994c0fedf6bff69a325fc48c3c89a397b4b1682cb8519c2059f&fid=1684424001-250528-53404473674615&time=1480915931&sign=FDTAXGERLBH-DCb740ccc5511e5e8fedcff06b081203-WNytNOmBWfMPX6Qaqi8dzNQ3xYk%3D&to=d7&fm=Nin,B,T,t&sta_dx=35951160&sta_cs=1854&sta_ft=gz&sta_ct=0&sta_mt=0&fm2=Ningbo,B,T,t&newver=1&newfm=1&secfm=1&flow_ver=3&pkey=14004bfeb22f2f876825db70d9820d164343a6bde64f000002249238&sl=79036494&expires=8h&rt=sh&r=310023027&mlogid=7875448359956317706&vuk=1684424001&vbdid=1029378553&fin=mysql-5.6.13.tar.gz&fn=mysql-5.6.13.tar.gz&slt=pm&uta=0&rtype=1&iv=0&isw=0&dp-logid=7875448359956317706&dp-callid=0.1.1&csl=105&csign=a55iXbfzi23yAiPbzlK%2FEqzk8XQ%3D&wshc_tag=0&wsts_tag=5844fbdb&wsid_tag=79232df0&wsiphost=ipdbm
mkdir /D/programfiles/MySql -p # 创建待安装MySql目录
groupadd mysql # 添加mysql用户组
useradd -s /sbin/nologin -g mysql mysql # 在mysql用户组中添加mysql用户(mysql不允许登录)
yum install cmake # 安装编译工具
yum install bison # Yacc-like分析器生成器(生成解释器,编译器,协议实现工具)
yum install gcc gcc-c++ # 安装c++编译器
yum install ncurses-devel # 字符处理等级库
tar -zxvf mysql-5.6.13.tar.gz -C /D/programfiles
cd /D/programfiles/mysql-5.6.13
cmake -DCMAKE_INSTALL_PREFIX=/D/programfiles/MySql -DMYSQL_UNIX_ADDR=/D/programfiles/MySql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/D/programfiles/MySql/data
-DCMAKE_INSTALL_PREFIX # 安装目录
-DMYSQL_UNIX_ADDR # 连接数据库socket路径
-DDEFAULT_CHARSET # 默认编码
-DINSTALL_DATADIR # 数据库存放目录
-DDEFAULT_COLLATION # 校验字符
-DWITH_EXTRA_CHARSETS:STRING # 扩展字符集
-DWITH_MYISAM_STORAGE_ENGINE # 支持MyIASM引擎
-DWITH_INNOBASE_STORAGE_ENGINE # 支持InnoDB引擎
-DWITH_READLINE # 快捷键功能
-DENABLED_LOCAL_INFILE # 是否允许从本地导入数据
-DMYSQL_DATADIR # 数据文件存放位置
make
make install
/D/programfiles/MySql/scripts/mysql_install_db --user=mysql --basedir=/D/programfiles/MySql --datadir=/D/programfiles/MySql/data
或(5.7几的版本)
/D/programfiles/MySql/bin/mysqld --initialize --datadir=/D/programfiles/MySql/data --user=mysql --basedir=/D/programfiles/MySql
mkdir /D/programfiles/MySql/logs -p
/D/programfiles/MySql/bin/mysqld_safe --user=mysql
ln -s /D/programfiles/MySql/my.cnf /etc/my.cnf
ln -s /D/programfiles/MySql/lib /usr/lib/mysql
ln -s /D/programfiles/MySql/include /usr/include/mysql
ln -s /D/programfiles/MySql/bin/mysql /usr/bin/mysql
ln -s /D/programfiles/MySql/bin/mysqldump /usr/bin/mysqldump
ln -s /D/programfiles/MySql/bin/myisamchk /usr/bin/myisamchk
ln -s /D/programfiles/MySql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
chmod +w /D/programfiles/MySql
chown -R mysql:mysql /D/programfiles/MySql
cp /D/programfiles/MySql/support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
basedir=/D/programfiles/MySql
datadir=/D/programfiles/MySql/data
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
/etc/init.d/mysqld start 或 service mysqld start
mysql
或
mysql -u root -p
/etc/init.d/mysqld stop 或 service mysqld stop
cp /D/programfiles/MySql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf # 修改my.cnf(添加一些内容)
[mysqld]
#用户
user=mysql
#启动MySql的临时文件
socket=/D/programfiles/MySql/mysql.sock
#MySql根路径
basedir=/D/programfiles/MySql
#MySql数据存放目录
datadir=/D/programfiles/MySql/data
#启动MySql的临时文件
pid-file=/D/programfiles/MySql/mysqld.pid
#MySql错误日志目录
log-error=/D/programfiles/MySql/logs/mysqld.log
[mysqld_safe]
pid-file=/D/programfiles/MySql/mysqld.pid
log-error=/D/programfiles/MySql/logs/mysqld.log
[client]
port=3306
socket=/D/programfiles/MySql/mysql.sock
http://www.osyunwei.com/archives/5970.html
mysqld_safe error: log-error set to ‘/D/programfiles/MySql/logs/mysqld.log’, however file don’t exists. Create writable for user ‘mysql’
原因:没有指定路径,且没有该路径的权限
解决:
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb
mysqld_safe error: log-error set to ‘/D/programfiles/MySql/logs/mysqld.log’, however file don’t exists. Create writable for user ‘mysql’.
mkdir /D/programfiles/MySql/logs
touch /D/programfiles/MySql/logs/mysqld.log
chown -R mysql:mysql /D/programfiles/MySql/logs
error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
原因:缺少libaio.so.1包
解决:yum install libaio
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
原因:没有配置[client]的socket,应该和[mysqld]中的socket配置一致
解决:配置[client]的socket
Access denied for user ‘root’@‘localhost’ (using password: YES)
原因:没权限
解决:先在[mysqld]中配置skip-grant-tables然后去设置权限,再删除
(HY000): You must reset your password using ALTER USER statement before executing this statement.
原因:没有设置远程权限
解决:修改mysql的root用户密码(即可生效)
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘111111’;
或(当有设置Host=‘%‘时使用如下语句)
ALTER USER ‘root’@’%’ IDENTIFIED BY ‘111111’;
flush privileges;