ubuntu安装mysql
1. 安装cmake: sudo apt-get install cmake
2.安装MySQL5.5
a) 下载:sudo wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.40.tar.gz
b) 解压并进入目录: sudo tar zxvf mysql-5.5.40.tar.gz && cd mysql-5.5.40
c) 编译安装:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/root/mysql/data/ -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0
------------
sudo cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/home/wkubuntu/mysql/data/ -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0
【常见错误一:Make Error at cmake/readline.cmake:83 (MESSAGE):
Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.】
--------------------------------------------------------------------------------------------------------------------------------------------------
解决方案:
删除:CMakeCache.txt($:rm CMakeCache.txt);
如果系统是Ubuntu,安装libncurses5-dev($:apt-get install libncurses5-dev );
如果系统是CentOS,安装ncurses-devel(yum install ncurses-devel)
********
【常见错误二:-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,】
------------------------------------------------------------------------
[root@localhost mysql-5.5.11]# rm CMakeCache.txt
[root@localhost mysql-5.5.11]# yum install ncurses-devel 【apt-get install ncurses-devel】
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /software/mysql-5.5.11
[root@localhost mysql-5.5.11]# yum install bison【apt-get install bison】
[常见错误三:CMAKE_CXX_COMPILER not set, after EnableLanguage CMake Error: Internal CMake error, TryCompile confi ]
解决方案:
sudo apt-get install g++
出现各种错误之后, rm -rf mysql-5.5.40 删掉之后重新编译即可。
d)make
e)make install
f) 配置
sudo cp support-files/my-medium.cnf /etc/my.cnf
sudo cp support-files/mysql.server /etc/init.d/mysqld
sudo chmod 755 /etc/init.d/mysqld
e) 初始化MySQL
- groupadd mysql //创建mysql组
- useradd -g mysql mysql //创建mysql用户添加到mysql组
- sudo sh ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/home/wkubuntu/mysql/data/
三、 启动和停止MySQL
sudo /etc/init.d/mysqld start
sudo /etc/init.d/mysqld stop
【常见错误4:Couldn't find MySQL server (/usr/bin/mysqld_safe)】
-------------------------
解决方案:sudo rm /etc/mysql/my.cnf
【 MySQL: Starting MySQL….. ERROR! The server quit without updating PID file解决方法】
cd /usr/local/mysql/
chown -R mysql:mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$ scripts/mysql_install_db
/usr/local/mysql/bin/mysqld_safe --user=mysql &
b) 安装连接MySQL客户端
sudo apt-get install mysql-client
c) 连接MySQL测试
mysql –u root
-------------------------------------------
The program 'mysql' can be found in the following packages:
* mysql-server-core-5.1
* mysql-cluster-server-5.1
* mysql-server-core-5.0
Try: apt-get install <selected package>
并不是真的错误而不错
是因为编译安装mysql的
mysql/bin目录没有添加到path里面
所以要cd 到mysql/bin目录下然后 ./mysql 或者 .bin/mysql -uroot -p
【注:直接进入目录cd /usr/local/ 然后 sudo ./mysql -uroot -p】
参考文章:http://www.itpub.net/forum.php?mod=viewthread&tid=1811682&highlight=
---------------------------------------------
常见错误-bash: mysql: command not found
mysql命令不能用
解决方案:ln -s /usr/local/mysql/bin/mysql /usr/bin
.. * The server quit without updating PID file (/home/wkubuntu/mysql/data/iZ25xi5chxrZ.pid).
没解决。。