groupadd mysql #添加mysql組
useradd -g mysql -s /sbin/nologin mysql #創建用戶mysql並加入到mysql組,不允許mysql用戶直接登錄系統
mkdir -p /data/mysql #創建MySQL數據庫存放目錄
chown -R mysql:mysql /data/mysql #設置權限
tar -zxf mysql-5.6.30.tar.gz
cd mysql-5.6.30
cmake . -DCMAKE_INSTALL_PREFIX=/web/mysql -DMYSQL_DATADIR=/web/mysql/data -DWITH_INNODB_MEMCACHED=ON
make&&make install
cd /web/mysql
初始化
./scripts/mysql_install_db --user=mysql #生成mysql系統數據庫
加入自啟動
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系統啟動
chkconfig mysqld on #加入開機啟動
裝完MySQL修改my.cnf
datadir=/data/mysql 數據庫路徑
添加環境變量 /etc/profile 末行 source /etc/profile生效
PATH=/web/mysql/bin:$PATH
export PATH
此時輸入MySQL可直接進入
不進入mysql
mysqladmin -u root -p password ’123’ 設置密碼
進入MySQL
update user set password='' where user='root'; 修改密碼 ’’為空是空密碼。。 ’123’ 為密碼是123
service mysqld restart #重啟
備注: cmake 編譯mysql 時報錯
CMake Error at cmake/readline.cmake:85 (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.
Call Stack (most recent call first):
cmake/readline.cmake:128 (FIND_CURSES)
cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:409 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
該報錯原因是未安裝ncurses-devel,安裝
#yum -y install ncurses-devel 刪除CMakeCache.txt locate CMakeCache.txt #使用locate時 報錯,執行命令updatedb # rm -rf /usr/local/src/cmake-2.8.8/Tests/Complex/Cache/CMakeCache.txt