Home >Database >Mysql Tutorial >Let's talk about the cmake method of mysql

Let's talk about the cmake method of mysql

藏色散人
藏色散人forward
2021-10-19 16:28:242632browse

This article will give you a brief analysis of the cmake method of installing mysql, and introduce some knowledge of the cmake method. I hope it will be helpful to everyone!

is generally divided into the following types

yum
rpm package
Conventional compilation and installation
cmake installation
Binary package installation free

How to choose

Personal useYum or rpm package installation

Enterprise useUse regular compilation Free installation with cmake and binary packages

If the quantity is small
For the 5.1.x version, choose to use regular compilation and installation
For the 5.5.x version, choose to use cmake to compile and install

If the quantity is large
Use the binary package directly without installation

First check the system environment

[root@localhost ~]# cat /etc/redhat-release 
CentOS release 6.5 (Final)
[root@localhost ~]# uname -r
2.6.32-431.el6.x86_64
[root@localhost ~]# uname -m
x86_64

When installing cmake software, you need to install gcc and gcc-c

yum -y install gcc

yum -y install gcc-c

After compiling and installing cmake, you need to install dependency packages

yum install ncurses-devel -y

Remember first To install users and groups
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd mysql -s /sbin/nologin -M -g mysql

Dependent packages are installed After that, cd into the mysql directory for cmake operation

cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0 \


-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \           貌似因为64位主机编译不过去!!!
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all "
执行成功返回下面代码

Build files have been written to: /root/lamp/mysql-5.5.32

make && install
安装完成

[100%] Built target my_safe_process #This Make completion
....
....
....
-- Installing: /application/mysql-5.5.32/support-files/solaris/postinstall-solaris # Here make install is completed

建立link

ln -s /application/mysql-5.5.32/ application/mysql

建立my.cnf

[root@localhost /]# cp /application/mysql-5.5.32 /support-files/my-small.cnf /etc/my.cnf
cp: Overwrite "/etc/my.cnf"? y

配置环境变量

echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile
tail -l /etc/profile
source /etc/profile
echo $PATH

给mysql用户和mysql用户组授权

chown -R mysql.mysql /application/mysql/data/

chmod -R 1777 /tmp/

初始化db脚本,假如有两个ok,就证明成功

[root@localhost / ]# cd /application/mysql/scripts/
[root@localhost scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

修改hosts文件

vim /etc/hosts

Join www

加入mysqld脚本

cp /root/lamp/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld

加入mysqld脚本执行权限

chmod x /etc/init.d/mysqld

执行mysqld运行

[root@localhost scripts]# /etc/init.d/mysqld start
Starting MySQL...                                                                                                                                                                                                                                                        0 0 0.0.0.0:3306 0.0.0.0:* 2671/mysqld

进入mysql服务器,如果之前配置了环境变量了,就可以执行mysql命令

mysql
删除空用户

##mysql> select user ,host from mysql.user ;userhost -- ---- ----------------------- root127.0.0.1root::1# #localhostlocalhost##localhost.localdomainrootlocalhost.localdomainmysql> delete from mysql.user where user ='';Query OK, 2 rows affected (0.09 sec)



root

6 rows in set (0.00 sec)

##mysql> select user,host from mysql.user;

hostroot##rootlocalhostrootlocalhost.localdomain##4 rows in set (0.00 sec)mysql> ;mysql> grant all privileges on . to system@'localhost' identified by 'longjq' with grant option;

user
---- -----------------------

127.0.0.1
root ::1
授权system管理员
Query OK, 0 rows affected (0.00 sec)

修改mysql密码
/application/mysql//bin/mysqladmin -u root password '123456'

/application/mysql//bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Rrieee

[root@localhost scripts]#chKConfig -List mysqld mysqld 0: Close 1: Close 2: Enlightenment 3: Enlightenment 5: Enlighten 6: Close

##Troubleshooting


Can’t log in to mysql? Delete the file and re-initialize

加入启动管理

Character set error?

# mysql
access denied for user 'localhost'......
# pkill mysqld
# lsof -i :3306
# rm -fr /application/mysql/data/*
# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Recommended learning: "mysql video tutorial

"

The above is the detailed content of Let's talk about the cmake method of mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete