CentOS Linux 7 source installation MySQl 5.6.14 (weak password available)

Environment preparation:

  1. Open the terminal and use the command to query whether there are mysql-related dependencies, components, etc.
rpm -qa | grep mysql

Because it was installed when I wrote the blog, so there are no pictures

  1. If there is, use the command to uninstall
rpm -e *** // 普通删除
rpm -e *** // 强力删除模式:***为依赖名称

start installation

one installation

  1. Download the installation package and copy it to the /opt directory (I don't know if it can be placed in other directories)
    Version 5.6.22 Version
    5.6.14

  2. install make gcc-g++ emake

yum -y install make gcc-g++ cmake bison-devel ncurses-devel

Note: The installation time here may be longer, about half an hour

  1. Unzip the downloaded source package and enter the unzip directory
tar -zxvf 文件名
cd 解压好的目录名
  1. compile
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1

Note: Here is a command not multiple sentences
/user/local is the installation directory, you can also put it in another directory for personal testing

Error solution:
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb
Error reason: missing file
Solution:
yum install 'perl(Data::Dumper)'

  1. compile and install
make && make install

Note: It takes about half an hour to 40 minutes. Warnings and red statements during compilation are not errors, so don’t ignore them.

Two configure mysql group and user

  1. Create mysql user and mysql user group and modify the folder permissions (if there is, just modify the folder permissions directly)
// 查看用户列表
cat /etc/passwd
// 查看用户组列表
cat /etc/group

// 创建用户组
groupadd mysql
// 创建用户并且放到mysql组
useradd -g mysql mysql

// 由于安装的时候是安装到了/usr/local/mysql文件夹. 
// 所以要把这个文件夹的所属修改成刚刚创建的mysql组和mysql用户
chown -R mysql:mysql /usr/local/mysql

Three initialization mysql

  1. Go to the installation folder of mysql
cd /usr/local/mysql
  1. Initialize the database and tables that come with the system
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
  1. Modify the configuration file.
    Some systems will create the my.cnf file in the /etc folder during installation. Because the MySQL database reads the configuration priority, it first goes to the /etc folder to find the my.cnf file. If not, it will arrive We are looking for my.cnf in the mysql installation directory, so we need to modify the my.cng file in the /etc folder (to prevent interference) and let him read the my.cnf file in the installation directory
mv /etc/my.cnf /etc/my.cnf.bak
  1. configure boot
1、拷贝脚本
cp support-files/mysql.server /etc/init.d/mysql
2、添加服务mysql
chkconfig --add mysql
3、设置mysql服务为自启动
chkconfig mysql on

5) Start mysql and enter the database, change the password

// 1、启动mysql
service mysql start
// 2、进入/usr/local/mysql/bin文件夹
cd /usr/local/mysql/bin
// 3、进入数据库(出世密码为空)
./mysql -u root -p 或 ./mysql -u root
// 4、修改数据库密码
SET PASSWORD = PASSWORD('你的密码');
  1. Configure environment variables so that they can use mysql commands directly without entering the mysql bin directory to use
// 1 进入profile文件
vim /etc/profile
// 2 进入最后一行, 添加配置
PATH=/usr/local/mysql/bin:$PATH
// 3 刷新配置文件
source /etc/profile

write picture description here

  1. Have fun using it
    write picture description here

write at the end

I am a pure white, and the blog I wrote was also written because of the problems encountered in learning and use, after searching for materials and solving them. If there are errors in some places, or if there is any infringement, please contact me.

QQ : 994961015
E-mail: [email protected]
WeChat: This cannot be given.

Guess you like

Origin blog.csdn.net/qq_37274323/article/details/82192177