十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
下文我给大家简单讲讲关于MySQL数据库采用源码安装教程,大家之前了解过相关类似主题内容吗?感兴趣的话就一起来看看这篇文章吧,相信看完mysql数据库采用源码安装教程对大家多少有点帮助吧。
萨尔图网站建设公司创新互联建站,萨尔图网站设计制作,有大型网站制作公司丰富经验。已为萨尔图成百上千提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的萨尔图做网站的公司定做!
Mysql数据库采用源码安装
[root@server ~]# wget -c http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17.tar.gz [root@server ~]# tar -zxf mysql-5.7.17.tar.gz [root@server ~]# cd mysql-5.7.17 [root@server mysql-5.7.17]# yum install cmake ncurses-devel -y [root@server mysql-5.7.17]# cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ #指定套间字路径 -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ #设置字符集 -DDEFAULT_COLLATION=utf8_general_ci \ #设置字符校验集 -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost #指定Boost扩展源码路径
---------------------------------------------------------------
CMake Warning:
Manually-specified variables were not used by the project:
WITH_MEMORY_STORAGE_ENGINE
WITH_READLINE
-- Build files have been written to: /root/mysql-5.7.17
---------------------------------------------------------------
出现上面的结果表示预编译成功!
[root@server mysql-5.7.17]# make -j grep 'processor' /proc/cpuinfo | wc -l [root@server mysql-5.7.17]# make -j grep 'processor' /proc/cpuinfo | wc -l install
检查系统是否已经有mysql用户,如果没有则创建
[root@server mysql-5.7.17]# cat /etc/passwd | grep mysql [root@server mysql-5.7.17]# cat /etc/group | grep mysql
创建mysql用户(但是不能使用mysql账号登陆系统)
[root@server mysql-5.7.17]# groupadd mysql [root@server mysql-5.7.17]# useradd -g mysql -s /sbin/nologin mysql
修改权限
[root@server mysql-5.7.17]# chown -R mysql:mysql /usr/local/mysql
[root@server mysql-5.7.17]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf [root@server mysql-5.7.17]# vim /etc/my.cnf ################### [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock user=mysql #innodb_force_recovery=6 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-bin=mysql-bin server-id = 1 auto_increment_offset=1 auto_increment_increment=2 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/usr/local/mysql/mysqld.log pid-file=/usr/local/mysql/mysqld.pid # # include all files from the config directory # !includedir /etc/my.cnf.d
[root@server mysql-5.7.17]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@server mysql-5.7.17]# vim /etc/init.d/mysqld #####添加安装目录及数据目录 basedir=/usr/local/mysql datadir=/usr/local/mysql/data
[root@server mysql-5.7.17]# chkconfig --add mysqld [root@server mysql-5.7.17]# chkconfig --level 35 mysqld on
进入/etc/profile设置环境变量
[root@server mysql-5.7.17]# vim /etc/profile export PATH=/usr/local/mysql/bin:$PATH #在末尾添加 [root@server mysql-5.7.17]# source /etc/profile
进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
#mysql5.7之前版本初始化配置表命令:
#script/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/
#mysql5.7已经放弃使用了,而且也没有script目录,可以使用下面这个
#[root@server mysql-5.7.17]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/
生成的初始密码位于:
方法一:
[root@server mysql-5.7.17]# grep 'temporary password' /var/log/mysqld.log 2016-07-08T02:25:46.311098Z 1 [Note] A temporary password is generated for root@localhost: MtPqF0/oN5zo
即初始密码为 MtPqF0/oN5zo (密码是随机产生的,每台机器产生的都不一样哦)
方法二:
[root@server mysql-5.7.17]# cat /root/.mysql_secret # The random password set for the root userat Fri Jan 10 20:00:34 2014 (local time): aJqZsA2m
这里的aJqZsA2m就是生成的root随机密码啦
接下来,启动数据库,重设root密码
[root@server mysql-5.7.17]# /etc/init.d/mysqld start
[root@server mysql-5.7.17]# mysql -uroot -p Enter password: # 输入刚刚的随机密码链接数据库 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
大家觉得mysql数据库采用源码安装教程这篇文章怎么样,是否有所收获。如果想要了解更多相关,可以继续关注我们的行业资讯板块。