Linux/ubuntu under CMake compile MySQL tutorial

Source: Internet
Author: User
Tags chmod file copy mysql download mysql tutorial mysql version

Using Linux+vim to write PHP is simply a pleasure. Here is my VIM configuration and installation of Plug-ins.

1. Download MySQL 5.5.28 source pack
Download Address: http://www.mysql.com/downloads/mysql/#downloads

In the MySQL download page drop-down box select "Source Code", and then select the tar.gz format below, start the download. Wget begin to use: http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz this address.

2. Add MySQL users and groups

The code is as follows Copy Code

sudo groupadd MySQL

sudo useradd-r-g MySQL MySQL

3. Install some of the required software

The code is as follows Copy Code

sudo apt-get install cmake automake autoconf libtool gcc g++ Bison

If you install only the extensions above, this error will always occur in the compilation process:--Could not found Curses (missing:curses_library curses_include_path) CMake error at Cmake/rea  DLINE.CMAKE:83 (message): Curses library is not found. Please install appropriate package, remove CMakeCache.txt and rerun CMake. On Debian/ubuntu, package the name is Libncurses5-dev, in Redhat and derivates it is ncurses-devel., you need to install the Libncurses5-dev package more.
sudo apt-get install Libncurses5-dev


Tip, to ensure speed, please update the Ubuntu source as the fastest source: Ubuntu update source recommended.

4. CMake compile MySQL

The code is as follows Copy Code

#创建目录
sudo mkdir/data/mysql/

#开始编译 (Note that the following command is a sentence, the actual situation is not a newline, here to facilitate the annotation)
sudo cmake
-dcmake_install_prefix=/usr/local/mysql #安装路径
-dmysql_datadir=/data/mysql/#数据文件存放位置
-dsysconfdir=/etc #my. CNF path
-dwith_myisam_storage_engine=1 #支持MyIASM引擎
-dwith_innobase_storage_engine=1 #支持InnoDB引擎
-dwith_memory_storage_engine=1 #支持InnoDB引擎
-dwith_readline=1 #快捷键功能 (I didn't use them)
-dmysql_unix_addr=/tmp/mysqld.sock #连接数据库socket路径
-dmysql_tcp_port=3306 #端口
-denabled_local_infile=1 #允许从本地导入数据
-dwith_partition_storage_engine=1 #安装支持数据库分区
-DWITH_EXTRA_CHARSETS:STRING=UTF8,GBK #安装需要的字符集
-ddefault_charset=utf8 #默认字符
-ddefault_collation=utf8_general_ci #默认字符集

#make安装
sudo make && make install

5. Configure MySQL
In this step you need to be aware of the my.cnf loading sequence, the Linux priority from high to low/etc/my.cnf->/etc/mysql/my.cnf->sysconfdir/my.cnf-> $MYSQL _home/ MY.CNF, high priority MY.CNF settings will cover the lower priority of the MY.CNF, so the general config file copy to the etc can.

The code is as follows Copy Code

There's no my.cnf under the/etc #如果.
sudo cp support-files/my-medium.cnf/etc/my.cnf

#设置权限
sudo chmod +x/usr/local/mysql
sudo chown-r mysql.mysql/usr/local/mysql

#配置开机自启动
sudo cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql
sudo chmod +x/etc/init.d/mysql
sudo chkconfig–list
sudo update-rc.d mysql defaults '/sbin/chkconfig–add MySQL; /sbin/chkconfig MySQL on '
sudo chkconfig–list MySQL

#修改my. CNF Configuration
Vim/etc/my.cnf

#[mysqld] Add:
Datadir=/data/mysql
Default-storage-engine=myisam

#以下可选:
Log-error =/data/mysql/error.log
Pid-file =/home/mysql/mysql.pid
user = MySQL
Tmpdir =/tmp

#安装默认数据表
/usr/local/mysql/scripts/mysql_install_db–basedir=/usr/local/mysql–datadir=/da/mysql–user=mysql

#启动MySQL
/USR/LOCAL/MYSQL/BIN/MYSQLD_SAFE–DEFAULTS-FILE=/ETC/MY.CNF &
#或者
/etc/init.d/mysql Start (service MySQL start)

#测试MySQL是否启动
# 1 To see if there is process MySQL
Ps-ef | grep MySQL
# 2 To see if the port is running
NETSTAT-TNL | grep 3306
# 3 Read MySQL version information
Mysqladmin version
# #安装成功, god!

To this MySQL compilation completes, if this time MySQL cannot start, so many problems are basically in the MY.CNF position and the setup. Finally enter MySQL to modify the root password, the current password is blank:

The code is as follows Copy Code

UPDATE user SET Password=password ("New password") WHERE user= ' root ';
FLUSH privileges;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.