1、官网下载地址:https://cdn.MySQL.com//Downloads/MySQL-5.7/mysql-boost-5.7.29.tar.gz
【此包中含boost】
2、创建安装目录mkdir -p /usr/local/mysql
mkdir -p /data/mysql/data
3、创建用户和组groupadd mysql
useradd -g mysql mysql
4、授权chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysql/data
5、安装依赖包yum -y install make gcc gcc-c++ cmake bison-devel ncurses ncurses-devel openssl-devel bison
6、cmake编译cmake
-DWITH_BOOST=boost/boost_1_59_0
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/data/mysql/data
-DSYSCONFDIR=/etc
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_TCP_PORT=3306
-DENABLED_LOCAL_INFILE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DWITH_SSL=system
7、make编译make
【lscpu
make -j [需要添加编译的cpu数量,提高编译速度] 】
8、vi /etc/my.cnf[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
skip-name-resolve
#innodb_buffer_pool_size=2048M
max_connections=500
【Linux 安装mysql5.7.29源码安装】collation_server=utf8_bin
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
lower_case_table_names=0
key_buffer_size = 600M
max_allowed_packet = 100M
table_open_cache = 1024
sort_buffer_size = 6M
read_buffer_size = 6M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 64
query_cache_size = 256M
innodb_log_file_size = 1024M
innodb_log_files_in_group = 3
#log-error=/usr/local/mysql/log/mysqld.log
[client]
default-character-set = utf8
9、初始化cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data/
10、环境变量设置echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
11、复制启动文件:cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
12、启动数据库:/etc/init.d/mysqld start
13、修改临时密码alter user 'root'@'localhost' identified by 'ik0@110';
14、添加到开发服务chkconfig --add /etc/init.d/mysqld
15、设置开机启动chkconfig mysqld on
99、MySQL忘记root密码解决方法:
1)在my.cnf中加上skip-grant-tables后 service mysqld restart
2)登录后执行
update mysql.user set authentication_string=password(‘jew@110’) where user=‘root’;
flush privileges;
3)执行成功后将my.cnf 文件改回去,重启MySQL,使用新密码登录,MySQL已安装完成 。
4)然后mysql就可以连接了,但此时操作似乎功能不完全,还要alter user…
mysql> alter user 'root'@'localhost' identified by 'qldassword(‘r31@110’) where user=‘root’;
flush privileges;
3)执行成功后将my.cnf 文件改回去,重启MySQL,使用新密码登录,MySQL已安装完成 。
4)然后mysql就可以连接了,但此时操作似乎功能不完全,还要alter user…
mysql> alter user 'root'@'localhost' identified by 'qld@110';
推荐阅读
- 两个技巧帮你记住复杂 Linux 命令!
- timeout Linux中运行有时间限制的命令
- Linux 硬件故障排除指南
- 在 Linux 下使用 fstrim 延长 SSD 驱动器的寿命
- Linux性能调优,从优化思路说起
- 分享几款Linux 下C/C++程序内存泄漏检查工具
- 茶具安装视频教程,养生茶不刷赞如何上推荐
- Linux下查看端口占用
- Linux安装nfs文件服务器
- Linux 安装Git