从www.mysql.org 下载mysql的linux安装包,如:mysql-5.7.11-linux-glibc2.5-x86_64.tar
使用tar命令解压压缩包
再次解压 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz 和mysql-test-5.7.11-linux-glibc2.5-x86_64.tar.gz
最终得到 一个mysql-5.7.11-linux-glibc2.5-x86_64 文件夹
将此文件夹移动至/usr/local下,并改名为mysql
创建mysql用户和组,并将/usr/local/mysql的用户和组都设置为mysql
进入sumpport-files文件夹,将my-default.cnf复制到/etc目录下,并改名为my.cnf
初始化数据库
拷贝mysql.server至/etc/init.d目录下,并改名为mysqld
注册mysql至centos系统服务
重启mysql,并登陆mysql console,root默认密码为“初始化数据库”时获得密码
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
初次登录需要重置一次密码,解决方法如下
SET PASSWORD = PASSWORD('test123');
# 后续修改密码
update mysql.user set authentication_string=password('test123') where user='root' and Host = 'localhost';
flush privileges;
创建新用户
create user test1;
update mysql.user set authentication_string=password("test123") where user="test1";
grant all on *.* to 'test1'@'%';
flush privileges;
my.cnf配置
[mysqld]
# 默认字符集
# 5.1的写法
#default-character-set = utf8
# 5.7的写法
character-set-server = utf8
# 禁用DNS主机名查找
skip-name-resolve
# 接收的数据包大小
max_allowed_packet = 16M
# 最大连接数
max_connections=1000
# innodb引擎缓冲池大小,一般设置为内存的70%-80%
innodb_buffer_pool_size=128M
#事务数据写入磁盘策略
innodb_flush_log_at_trx_commit=2
# 不区分大小写
lower_case_table_names=1
mysql5.6的编译安装记录
cd mysql-5.6.23
CFLAGS="-O3 -g -fno-exceptions -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing"
CXX=g++
CXXFLAGS="-O3 -g -fno-exceptions -fno-rtti -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing"
export CFLAGS CXX CXXFLAGS
cmake . \
-DSYSCONFDIR:PATH=/usr/local/mysql \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DENABLE_PROFILING:BOOL=ON \
-DWITH_DEBUG:BOOL=OFF \
-DWITH_VALGRIND:BOOL=OFF \
-DENABLE_DEBUG_SYNC:BOOL=OFF \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_SSL:STRING=bundled \
-DWITH_UNIT_TESTS:BOOL=OFF \
-DWITH_ZLIB:STRING=bundled \
-DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON \
-DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON \
-DWITH_ARCHIVE_STORAGE_ENGINE:BOOL=ON \
-DWITH_BLACKHOLE_STORAGE_ENGINE:BOOL=ON \
-DWITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE:BOOL=ON \
-DWITH_EMBEDDED_SERVER=0 \
-DINSTALL_LAYOUT:STRING=STANDALONE \
-DCOMMUNITY_BUILD:BOOL=ON \
-DMYSQL_SERVER_SUFFIX='-r5436';
rpm -q cmake
rpm -q gcc-c++
rpm -q bison
rpm -q ncurses-devel
rpm -q zlib
yum install cmake
rpm -q ncurses-devel
yum install ncurses-devel
-- rm CMakeCache.txt
make
make install