日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

l源码安装mysql升级_[Linux]javaEE篇:源码安装mysql

發布時間:2025/3/21 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 l源码安装mysql升级_[Linux]javaEE篇:源码安装mysql 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

javaEE :源碼安裝mysql

安裝環境

系統平臺:CentOS-7-x86_64

數據庫版本:mysql-5.6.14

源碼安裝mysql步驟:

一、卸載mysql

安裝mysql之前,先確保linux系統中沒有mysql的相關文件;

如果沒有,那么請忽略這一步的卸載過程。

如果有,那么把mysql卸載。

1、檢查是否有myql service

rpm -qa | grep mysql:檢查是否有mysql

2、如果有,卸載掉mysql

rpm -e mysql_libs==》rpm -e mysql具體包名:普通刪除模式

或者

rpm -e --nodeps mysql_libs==》rpm -e --nodeps mysql具體包名:強力刪除模式,如果使用上面命令刪除時,提示有依賴的其它文件,則用該命令可以對其進行強力刪除 。

二、安裝mysql

1、安裝編譯代碼需要的包

yum -y install make gcc-c++ cmake bison-devel ncurses-devel。直接將此指令復制粘貼執行。

2、下載MySQL ,并放到/usr/local目錄下

省略此步驟

3、解壓mysql源碼包,并進入mysql目錄中

tar xvf mysql-5.6.14.tar.gz:解壓mysql源碼包

cd /usr/local/mysql-5.6.14:進入到mysql目錄下

4、編譯安裝

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=

/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=

1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=

1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=

/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=

1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=

all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

復制上面這段指令,在/usr/local/mysql-5.6.14 (進入到mysql目錄下)執行這段指令。

執行完成后,再執行下面的這個指令:

make && make install

make && make install:編譯并安裝;&&表示執行完前面的這段指令,再執行后面的這個安裝指令。

這個一步大約需要半個小時。安裝完成,接下來就需要來配置我們的mysql了。

三、配置mysql

在設置權限之前,我們要先確定linux系統中是否有mysql用戶及用戶組

cat /etc/passwd:查看用戶列表

cat /etc/group:查看用戶組列表

如果沒有就進行創建mysql用戶及mysql用戶組

groupadd mysql:創建mysql用戶組

useradd -g mysql mysql:創建mysql用戶,并設置這個用戶為mysql組。

下面就正式進入到:設置權限

1、設置權限

在設置mysql權限之前,我們先來查詢一下這個文件的信息

[root@localhost local]# ls -l | grep mysql

drwxr-xr-x. 13 root root 213 May 5 00:15 mysql

chown -R mysql:mysql /usr/local/mysql:修改/user/local/mysql的權限

修改完權限,重新查看一下mysql的信息

[root@localhost local]# ls -l | grep mysql

drwxr-xr-x. 13 mysql mysql 213 May 5 00:17 mysql

修改權限成功!!

2、初始化配置

進入到安裝路徑(并執行下面的這段指令),執行初始化配置腳本,創建系統自帶的數據庫和表。

cd /usr/local/mysql:進入到安裝路徑

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql:這是一條指令

注意:執行上面這條指令報錯

WARNING: Default config file /etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

--defaults-file argument to mysqld_safe when starting the server

報錯原因:在CentOS 7版操作系統的最小安裝完成后,在/etc目錄下會存在一個my.cnf,需要將此文件更名為其他的名字,如:/etc/my.cnf.bak,否則,該文件會干擾源碼安裝的MySQL的正確配置,造成無法啟動。修改名稱,防止干擾:

解決方法:mv /etc/my.cnf /etc/my.cnf.bak

注:在啟動MySQL服務時,會按照一定次序搜索my.cnf,先在/etc目錄下找,找不到則會搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,這是新版MySQL的配置文件的默認位置!

三、啟動mysql

添加服務,拷貝服務腳本到init.d目錄,并設置開啟啟動。

注意:是在/usr/local/mysql下執行的

shell

[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql

[root@localhost mysql]# chkconfig mysql on

[root@localhost mysql]# service mysql start

Starting MySQL.. SUCCESS!

上面是的指令就是啟動mysql所用到的;

第一行:進入到/usr/local/mysql目錄下;

第二行:拷貝服務腳本到init.d目錄;

第三行:設置開機啟動;

第四行:啟動Mysql

四、使用mysql

執行下面的命令,進行修改密碼:

[root@localhost mysql]# cd /usr/local/mysql/bin

[root@localhost bin]# ./mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.14 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password =password('root');

Query OK, 0 rows affected (0.01 sec)

mysql> quit //退出指令

Bye

[root@localhost bin]# ./mysql -uroot

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@localhost bin]# ./mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.14 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases; // 查看mysql中數據庫

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.03 sec)

mysql>

第一行:cd /usr/local/mysql/bin,進入該目錄

第二行:./mysql -uroot

第十一行:set password =password('root');:修改數據庫密碼

第十三行:quit;退出

第十七行:./mysql -u root -p;重新登錄mysql,輸入密碼

第 三十一 行:show databases;查看mysql中數據庫

接著在上面的基礎上,來創建一張user表,并插入兩條數據

mysql> create database myDB; //創建數據庫:myDB

Query OK, 1 row affected (0.00 sec)

mysql> use myDB; //使用數據庫:myDB

Database changed

mysql> show databases; //查詢列出所有數據庫

+--------------------+

| Database |

+--------------------+

| information_schema |

| myDB |

| mysql |

| performance_schema |

| test |

+--------------------+

5 rows in set (0.00 sec)

mysql> create table user(id int, name varchar(32)); //創建表:user

Query OK, 0 rows affected (0.01 sec)

mysql> insert into user values(100,'tom'); //插入數據:user

Query OK, 1 row affected (0.00 sec)

mysql> insert into user values(1,'tom');

Query OK, 1 row affected (0.00 sec)

mysql> insert into user values(2,'王春蘭');

Query OK, 1 row affected (0.00 sec)

mysql> select * from user; //查詢user表

+------+-----------+

| id | name |

+------+-----------+

| 100 | tom |

| 1 | tom |

| 2 | 王春蘭 |

+------+-----------+

3 rows in set (0.00 sec)

mysql>

五、配置全部變量

!!!重要

將/usr/local/mysql/bin目錄配置到全局變量的文件中去/etc/profile;

[root@localhost mysql]# pwd

/usr/local/mysql

[root@localhost mysql]# vim /etc/profile

//... ...省略部分內容

unset i

unset -f pathmunge

JAVA_HOME=/usr/local/java

// 注意將:/usr/local/mysql/bin配置到這來,前面用:隔開

PATH=$PATH:$JAVA_HOME/bin:/usr/local/mysql/bin

CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME PATH CLASSPATH

最后重啟服務 或者退出重新登錄

systemctl daemon-reload:服務重載

logout:退出

這時候我們就可以在任意位置登錄mysql了。

[root@localhost ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.6.14 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

總結

以上是生活随笔為你收集整理的l源码安装mysql升级_[Linux]javaEE篇:源码安装mysql的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。