mysql安裝

mysqladmin -u root -p oldpass password newpass

mysqladmin -u root -p123 password 123456

set password=password("123");

安裝MySQL

[root@zyg tmp]# file MySQL-5.6.22-1.el6.x86_64.rpm-bundle.tar

MySQL-5.6.22-1.el6.x86_64.rpm-bundle.tar: POSIX tar archive (GNU)

[root@zyg tmp]# tar xf MySQL-5.6.22-1.el6.x86_64.rpm-bundle.tar

[root@zyg tmp]# ls /tmp/

MySQL-client-5.6.22-1.el6.x86_64.rpm

MySQL-devel-5.6.22-1.el6.x86_64.rpm

MySQL-embedded-5.6.22-1.el6.x86_64.rpm

MySQL-server-5.6.22-1.el6.x86_64.rpm

MySQL-shared-5.6.22-1.el6.x86_64.rpm

MySQL-shared-compat-5.6.22-1.el6.x86_64.rpm

MySQL-test-5.6.22-1.el6.x86_64.rpm

可以看到得到了很多的rpm包鹃祖,這里面常用的包有MySQL-client-5.6.22-1.el6.x86_64.rpm和mMySQL-server-5.6.22-1.el6.x86_64.rpm,如果僅僅是想安裝一個MySQL的服務器使用的話溪椎,安裝這兩個包其實就足夠了,它包含了mysql的服務器端和客戶端軟件恬口。有些時候還需要MySQL-devel軟件包,這個包也常安裝校读,它里面包含了MySQL的庫文件以及頭文件,有些時候安裝一些其他的軟件需要調用到這些MySQL的庫文件和頭文件的時候就安裝MySQL-devel包祖能,比方說安裝MySQL proxy代理服務器歉秫,或者是mysql enterprise monitor監(jiān)控軟件可能都需要安裝mysql-devel軟件包,下面來安裝這些軟件包养铸。安裝方式可以采用兩種:

一種是rpm命令一個個安裝雁芙,在安裝過程中可能會遇到依賴性問題,需要手工去解決钞螟。

[root@zyg tmp]# rpm -ivh MySQL-client-5.6.22-1.el6.x86_64.rpm

Preparing... ########################################### [100%]

1:MySQL-client ########################################### [100%]

另外一個方式是使用yum命令的方式兔甘。

[root@node1 tmp]# yum install MySQL-server-5.6.22-1.el6.x86_64.rpm

安裝完畢之后,屏幕上打印出了很多的內容鳞滨,注意下面這句話:

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

一個隨機性的密碼已經為mysql的root 用戶設置好了洞焙,你可以在root家目錄下的.msyql_secret中看到這個密碼,這個是mysql 5.5版本之后新出現(xiàn)的一個特性拯啦,mysql 5.5之前的版本在安裝完之后闽晦,有一個非常重要的安全性隱患就是mysql 管理用戶和mysql root用戶是空密碼,所以對于一個剛剛安裝完成之后的mysql服務器來說提岔,任何人可以從任何地方使用空密碼直接訪問數(shù)據(jù)庫仙蛉,這是一個很不安全的事情,因此在5.5.以后在mysql安裝完之后會隨機性的為root用戶隨機設置一個密碼并且把它保存在root家目錄下的.msyql_secret文件中

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

你必須在你第一次連接mysql的時候重設這個密碼碱蒙。別的都干不了荠瘪,但是'SET PASSWORD這個命令是可以執(zhí)行的,可以去看相應的手冊赛惩,比如 password expired部分的介紹

這里提到了一個工具叫做mysql_secure_installation叫安全的安裝哀墓,這個安裝其實提供了幾個功能,讓我們在初次安裝MySQL之后呢喷兼,提供一些安裝上面的修改篮绰,建議大家在安裝完畢之后使用,后面還有一些介紹季惯,可以去mysql官方網站去看它的手冊吠各,還可以去shop.mysql.com買它的商品臀突,等等。

首先想要去操作mysql的時候贾漏,需要知道它給我們設置的隨機密碼是什么候学。我們來看一下

[root@zyg tmp]# cd

[root@zyg ~]# ls .mysql_secret

.mysql_secret

[root@zyg ~]# cat .mysql_secret

The random password set for the root user at Mon Dec 8 01:47:25 2014 (local time): T9YV_AZe_HIZoQ5z

.mysql_secret這個文件里面寫了隨機性的密碼。要連接mysql纵散,就需要把這些隨機密碼輸入進去梳码。

不過先不著急,先運行一下mysql_secure_installation這個命令伍掀,建議在第一次安裝完成之后先運行這個命令掰茶,如果你沒有運行mysql的話,當然無法對它進行一些安裝方面的設置和操作蜜笤。先把mysql這個服務啟動起來濒蒋。

[root@zyg ~]# service mysql start

Starting MySQL. [ OK ]

這里介紹一下,在mysql5.1版本之后瘩例,官方所發(fā)布的mysql的安裝包服務名稱就發(fā)生了變化啊胶,以前叫做mysqld,現(xiàn)在叫做mysql垛贤。另外需要注意一點的是焰坪,rhel發(fā)行版本的光盤中帶的mysql它的服務名稱仍然是mysqld期奔,所以這個名字不要忘記颗味,官方下的這個MySQL包叫做mysql,如果redhat發(fā)行的光盤當中叫做mysqld剃袍,我們可以使用service mysqld start 來啟動mysql善绎,或者也可以使用 /etc/init.d/mysqld start 通過腳本啟動它黔漂。這兩條命令作用是一樣的。

現(xiàn)在再來執(zhí)行mysql_secure_installation禀酱,接下來輸入.mysql_secret中的密碼炬守。輸入密碼之后它會問是否修改密碼,可以將密碼修改為一個容易記憶的剂跟,符合密碼復雜性要求的密碼减途,比方說至少八位以上數(shù)字大小寫字母特殊符號都有等等的要求。

[root@zyg ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

接下來它繼續(xù)問你曹洽,mysql在安裝完畢之后鳍置,它默認會創(chuàng)建一個匿名用戶,這個匿名用戶是用來進行mysql測試時使用的送淆,這個匿名用戶它允許任何人從任何地方登陸到mysql税产,但是不能干其他的一些事情,這個也是一個安全隱患,所以它會問你是否要移出匿名用戶辟拷,選擇yes移除撞羽,

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y

... Success!

接下來,root是只允許從本地登錄mysql的梧兼,所以在這里它給你提供了一個選項放吩,是否禁止root用戶從遠程的機器上登錄到這臺mysql智听,這個設置一般來說在生產環(huán)境當中應該選擇的是yes羽杰,也就是關閉。因為在生產環(huán)境當中往往注重mysql的安全性到推,所以對于mysql管理用戶的登錄是限制的非常嚴格的考赛,如果你需要用root用戶來登錄mysql的話,往往先是ssh遠程連接的方式莉测,先登錄到具體的服務器上颜骤,然后在這臺服務器的本地使用root用戶來登錄。當然對于其它一些要求不嚴格的情況下捣卤,是允許root用戶遠程登錄的忍抽,所以說這個選項是否選擇,要看具體公司的安全要求董朝,來針對性選擇鸠项。這里選擇n,允許root用戶遠程登錄子姜。

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n

... Success!

接下來祟绊,默認情況下mysql在安裝的時候會創(chuàng)建一個叫做test的庫,這個庫任何人都可以進行訪問哥捕,這個庫的用途是用于測試的牧抽,所以說問你是否要移除test數(shù)據(jù)庫,y移除

By default, MySQL comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y

  • Dropping test database...

... Success!

  • Removing privileges on test database...

... Success!

接下來是否重讀一下授權表遥赚,這樣可以對mysql相應的授權扬舒,剛才所發(fā)生的一些修改,保證它立即生效凫佛,yes讲坎。這樣一來的可以安全放心的使用mysql了。

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

Cleaning up...

1.安裝客戶端

2.安裝服務端

3.啟動服務

4.復制密碼

5.更新密碼

6.設置選項

7登錄服務器

接下來介紹mysql客戶端的一些使用御蒲,客戶端的使用分為兩種:

客戶端使用

· 交互式

· 非交互式

最為常用的往往是交互式衣赶,而非交互式往往在某一些特殊需要下才進行使用。

首先來看厚满,最為基本的客戶端就是mysql這個命令了府瞄。

范例一:mysql -h 192.168.0.1 -P 3306 -uroot -p123 [dbname]

范例二:mysql -e “create database power”

mysql命令后面可以跟上很多相應的參數(shù),不同的參數(shù)起到不同的作用,看一下這些參數(shù)的使用遵馆。

常見參數(shù) 解釋


-u 指定登錄用戶名

-p 指定登錄密碼

-h 指定數(shù)據(jù)庫主機地址

-P 指定登錄端口

dbname 指定操作數(shù)據(jù)庫

-e 使用非交互式操作

-P 指定登錄msyql服務器的端口鲸郊,默認端口是3306,如果在設置服務器的時候將服務器的端口改成別的了货邓,在這里可以指定別的端口號秆撮,比方說3300。

-p 如果為-u指定的用戶設置了密碼换况,那么-p就必須指定职辨,如果沒有為用戶設置密碼,這個用戶是空密碼戈二,一般來說是不會這么做的舒裤,假設說沒有密碼,不指定-p 也可以觉吭,直接就可以登錄腾供。

注意-p之后如果要寫密碼的話,一定要緊跟著-p之后寫密碼-ppasswd鲜滩,一旦-p后面發(fā)生了空格的話伴鳖,它就會認為這個密碼,并不像在命令行當中輸入徙硅,而是在enter之后提供給一個密碼提示符后面輸入密碼進行登錄榜聂,而空格之后的字符,它就會認為是要操作的數(shù)據(jù)庫的名稱闷游,因此有沒有空格區(qū)別很大峻汉,這一點一定要注意,前面這些參數(shù)可以沒有空格脐往,前面的參數(shù)是無所謂的休吠,有沒有空格都可以,但是一定要注意到特別是這個-p业簿,-p后面的空格就變得非常敏感了瘤礁,所以一般來說將-p參數(shù)放到最后來寫。方便寫完密碼之后梅尤,寫數(shù)據(jù)庫柜思。

[root@zyg ~]# mysql -h localhost -u root -p123

Warning: Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 25

Server version: 5.6.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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>

mysql> show databases; 查詢庫

mysql> create database db; 創(chuàng)建庫

mysql> use db; 切換庫

mysql> show tables ; 查詢表

mysql> create table test(id int,name char(10)); 創(chuàng)建表

mysql> desc test; 描述表結構

mysql> insert into test values(1,'robin'); 插入數(shù)據(jù)

mysql> select * from test; 查看數(shù)據(jù)

mysql> select database(); 查看當前所在庫

mysql> status; 查看數(shù)據(jù)庫當前詳細情況

rpm包mysql

數(shù)據(jù)存放目錄:/var/lib/mysql

日志:/var/lib/mysql/robin.com.err

套接字文件:/var/lib/mysql/mysql.sock 網絡登錄修改套接字文件

端口:3306

現(xiàn)在要登錄到本機的數(shù)據(jù)庫上,假如說直接使用數(shù)據(jù)庫的管理員用戶root用戶巷燥,其實這樣一來參數(shù)就會大大的簡化赡盘,因為一些可選性的參數(shù)就可以不寫了,可以直接寫mysql -p就可以了缰揪,-h不寫默認就是本機陨享,所以說可以省略的,-u參數(shù)不寫默認使用root用戶登錄,也可省略抛姑,-P不寫默認使用端口3306赞厕,數(shù)據(jù)庫端口沒有改過,默認就是3306定硝,所以說這個也可以不寫皿桑,-p一定要寫,因為給root用戶設置過密碼蔬啡,數(shù)據(jù)庫名稱也可以不寫诲侮,可以進入數(shù)據(jù)庫之后再去指定,所以最簡化的方式就是mysql -p星爪,-p后面也不跟密碼直接enter浆西,會看到在下一行當中它會提示你輸入密碼粉私,可以再這里輸入密碼顽腾,而且在這里輸入密碼還有一個好處,密碼并不會直接顯示在終端上诺核。這樣更加安全一些抄肖。enter之后你會看到mysql的歡迎信息,并且提示符會變成mysql跟著一個>大于符號窖杀,這就代表登錄成功了漓摩,就連接到了mysql的數(shù)據(jù)庫里面。

[root@zyg ~]# mysql -p

Enter password:

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

Your MySQL connection id is 26

Server version: 5.6.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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>

mysql> show databases; 查看數(shù)據(jù)庫

mysql> create database db; 創(chuàng)建數(shù)據(jù)庫

mysql> use db; 切換庫

mysql> show tables; 查看表

mysql> create table test(id int,name char(10)); 創(chuàng)建表

mysql> desc test; 描述表

mysql> insert into test values(1,'robin'); 插入數(shù)據(jù)

mysql> select * from test; 查看數(shù)據(jù)

實驗環(huán)境清除密碼(數(shù)據(jù)會丟失)

service mysql stop

rm -rf /var/lib/mysql/*

mysql_install_db --user=mysql

service mysql restart

連接數(shù)據(jù)庫無密碼

============================================================================================================

編譯安裝MySQL

MySQL自5.5版本以后入客,就開始使用CMake編譯工具了管毙,因此,在安裝源文件中找不到configure文件是正常的桌硫。

[root@zyg tmp]# tar xf cmake-3.1.0-rc2.tar.gz -C /usr/local/src

[root@zyg tmp]# cd cmake-3.1.0-rc2

[root@zyg cmake-3.1.0-rc2]# ./configure --prefix=/usr/local/cmake

[root@zyg cmake-3.1.0-rc2]# make

[root@zyg cmake-3.1.0-rc2]# make install

下表列出了常用編譯工具的調用語法和等效的CMake命令夭咬。“.”表示當前的工作目錄路徑铆隘,請根據(jù)所在的目錄卓舵,適當?shù)奶鎿Q掉路徑“.”。

configure命令 CMake命令


./configure cmake .

./configure --help cmake . -LH or ccmake .

在重新配置或重新構建之前膀钠,需要先清除舊的對象文件和緩存信息:

make clean

rm CMakeCache.txt

安裝參數(shù)選項

在下表中掏湾,“CMAKE_INSTALL_PREFIX”的值表示的是安裝根目錄,其他參數(shù)值的路徑都是相對于根目錄的肿嘲,當然也可以直接使用絕對路徑:

參數(shù)值說明 配置選項 CMak選項


安裝根目錄 --prefix=/usr -DCMAKE_INSTALL_PREFIX=/usr

mysqld目錄 --libexecdir=/usr/sbin -DINSTALL_SBINDIR=sbin

數(shù)據(jù)存儲目錄 --localstatedir=/var/lib/mysql -DMYSQL_DATADIR=/var/lib/mysql

配置文件(my.cnf)目錄 --sysconfdir=/etc/mysql -DSYSCONFDIR=/etc/mysql

插件目錄 --with-plugindir=/usr/lib64/mysql/plugin -DINSTALL_PLUGINDIR=lib64/mysql/plugin

手冊文件目錄 --mandir=/usr/share/man -DINSTALL_MANDIR=share/man

共享數(shù)據(jù)目錄 --sharedstatedir=/usr/share/mysql -DINSTALL_SHAREDIR=share

Library庫目錄 --libdir=/usr/lib64/mysql -DINSTALL_LIBDIR=lib64/mysql

Header安裝目錄 --includedir=/usr/include/mysql -DINSTALL_INCLUDEDIR=include/mysql

信息文檔目錄 --infodir=/usr/share/info -DINSTALL_INFODIR=share/info

存儲引擎選項

存儲引擎是以插件的形式存在的融击,所以,該選項可以控制插件的構建雳窟,比如指定使用某個特定的引擎尊浪。

--with-plugins配置選項接受兩種形式的參數(shù)值,它沒有對應的CMake配置參數(shù):

① 以逗號(,)分隔的引擎名稱列表;

② a "group name" value that is shorthand for a set of engines

在CMake中际长,引擎被作為單個的選項來進行控制耸采。假設有以下配置選項:

--with-plugins=csv,myisam,myisammrg,heap,innobase,archive,blackhole

上面的參數(shù)指定MySQL數(shù)據(jù)庫可以支持哪些數(shù)據(jù)庫引擎,將上述編譯選項轉換成CMake編譯選項時工育,下面的幾個引擎名字可以被省略虾宇,因為編譯時,默認就支持:

csv myisam myisammrg heap

然后使用下面的編譯參數(shù)如绸,以啟用InnoDB嘱朽、ARCHIVE和BLACKHOLE引擎支持:

-DWITH_INNOBASE_STORAGE_ENGINE=1

-DWITH_ARCHIVE_STORAGE_ENGINE=1

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

當然也可以使用“ON”來替代數(shù)字1,它們是等效的怔接。

如果想除去對某種引擎的支持搪泳,則在CMake編譯選項中使用-DWITHOUT_<ENGINE>_STORAGE_ENGINE,例如:

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1

-DWITHOUT_FEDERATED_STORAGE_ENGINE=1

-DWITHOUT_PARTITION_STORAGE_ENGINE=1

庫文件加載選項

該選項指明Mysql使用庫的情況:

參數(shù)值說明 配置選項 CMake選項


readline庫 --with-readline -DWITH_READLINE=1

SSL庫 --with-ssl=/usr -DWITH_SSL=system

zlib庫 --with-zlib-dir=/usr -DWITH_ZLIB=system

libwrap庫 --without-libwrap -DWITH_LIBWRAP=0

其他選項

CMake編譯選項支持大部分之前版本的MySQL編譯選項扼脐,新老編譯選項的差別在于:之前的是小寫岸军,現(xiàn)在全部變成了大寫,之前采用雙橫線瓦侮,現(xiàn)在使用單橫線艰赞,之前使用的破折號,現(xiàn)在取而代之的是使用下劃線肚吏,例如:

--with-debug => WITH_DEBUG=1

--with-embedded-server => WITH_EMBEDDED_SERVER

下面是編譯MySQL的新老參數(shù)對照表:

參數(shù)值說明 配置選項 CMak選項


TCP/IP端口 --with-tcp-port-=3306 -DMYSQL_TCP_PORT=3306

UNIX socket文件 --with-unix-socket-path=/tmp/mysqld.sock -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock

啟用加載本地數(shù)據(jù) --enable-local-infile -DENABLED_LOCAL_INFILE=1

擴展字符支持 --with-extra-charsets=all(默認:all) -DEXTRA_CHARSETS=all(默認:all)

默認字符集 --with-charset=utf8 -DDEFAULT_CHARSET=utf8

默認字符校對 --with-collation=utf8_general_ci -DDEFAULT_COLLATION=utf8_general_ci

Build the server --with-server 無

嵌入式服務器 --with-embedded-server -DWITH_EMBEDDED_SERVER=1

libmysqld權限控制 --with-embedded-privilege-control 無

安裝文檔 --without-docs 無

Big tables支持 --with-big-tables, --without-big-tables 無

mysqld運行用戶 --with-mysqld-user=mysql -DMYSQL_USER=mysql

調試模式 --without-debug(默認禁用) -DWITH_DEBUG=0(默認禁用)

GIS支持 --with-geometry 無

社區(qū)功能 --enable-community-features 無

Profiling --disable-profiling(默認啟用) -DENABLE_PROFILING=0(默認啟用)

pstack --without-pstack 無(新版移除該功能)

匯編字符串函數(shù) --enable-assembler 無

構建類型 --build=x86_64-pc-linux-gnu 沒有等效參數(shù)

交叉編譯主機 --host=x86_64-pc-linux-gnu 沒有等效參數(shù)

客戶端標志 --with-client-ldflags=-lstdc++ 無

線程安全標志 --enable-thread-safe-client 無

注釋存儲類型 --with-comment='string' -DWITH_COMMENT='string'

Shared/static binaries --enable-shared --enable-static 無

內存使用控制 --with-low-memory 無

tar -xvf mysql-5.6.22.tar.gz -C /usr/local/src/

[root@zyg mysql-5.6.22]# /usr/local/cmake/bin/cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_READLINE=1 \

-DMYSQL_TCP_PORT=3306 \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DENABLED_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

[root@zyg mysql-5.6.22]# make

[root@zyg mysql-5.6.22]# make install

錯誤1.....

Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

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:406 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!

解決:

yum install ncurses-devel

yum install ncurses-devel-5.7-3.20090208.el6.i686

rm -rf /usr/local/src/mysql-5.6.22/CMakeCache.txt

/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

[root@zyg mysql-5.6.22]# cd /usr/local/mysql/

[root@zyg mysql]# useradd -M -u 27 -s /sbin/nologin mysql

[root@zyg mysql]# ./scripts/mysql_install_db --user=mysql mysql初始化

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'

./bin/mysqladmin -u root -h zyg.power.com password 'new-password'

Alternatively you can run:

./bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default. This is

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

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

修改目錄文件擁有者所屬組

[root@robin mysql]# chown -R mysql.mysql /usr/local/mysql/

源碼

[root@robin mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql & 啟動mysql

登錄

[root@robin mysql]# /usr/local/mysql/bin/mysql

客戶端

[root@zyg mysql]# chown -R root.mysql /usr/local/mysql/

[root@zyg mysql]# chown -R mysql data

[root@zyg mysql]# vim /etc/profile 或者 /etc/bashrc

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

[root@zyg mysql]# source /etc/profile

服務端

[root@zyg mysql]# cp support-files/mysql.server /etc/init.d/mysqld 啟動腳本拷貝

[root@zyg mysql]# chmod +x /etc/init.d/mysqld

設置源碼mysql開機自啟動

[root@zyg mysql]# chkconfig --add mysqld

[root@zyg mysql]# chkconfig --list mysqld

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@zyg mysql]# service mysqld start

Starting MySQL.. [ OK ]

[root@zyg mysql]# netstat -tunpl | grep 3306

tcp 0 0 :::3306 :::* LISTEN 30509/mysqld

[root@zyg mysql]# mysql -uroot

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

Your MySQL connection id is 1

Server version: 5.6.22 Source distribution

Copyright (c) 2000, 2014, 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>

修改密碼

mysql> set password=password("123");

或者

[root@localhost mysql]# mysqladmin -u root -p123 password 123456

cmake解壓縮包

編譯安裝cmake

musql解壓縮包

編譯安裝mysql

修改/usr/local/mysql的擁有者和所屬組為mysql

啟動

鏈接

環(huán)境變量設置


apache源碼包安裝

tar jxvf ......

cd httpd....

./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite 動態(tài)模塊加載 和 支持地址重寫

注解:

--enable-so:讓apache核心裝載DSO

make && make install

啟動apache服務

/usr/local/apache2/bin/apachectl start

編譯php

解壓php- 到/usr/local/src下方妖,進入該目錄進行編譯工作

cd /usr/local/src/php-5.2.9

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php

--with-mysql=mysqlnd

--with-mysqli=mysqlnd

--with-pdo-mysql=mysqlnd

mysqlnd是php5.3以后版本加入的,5.3以下版本必須還是要編譯mysql罚攀。

注解:

--with-apxs2=/usr/local/apache2/bin/apxs:用apache的apxs工具把php編譯成apache的一個模塊

--with-mysql=/usr/local/mysql:與mysql結合

make && make install

拷貝php的配置文件

cp php.ini-production /usr/local/php/etc/php.ini

如果一切順利的話党觅,apache2/modules 下應該有個libphp5.so 的文件

為apache 添加php 支持

編輯/usr/local/apache2/conf/httpd.conf 文件

增加一行

AddType application/x-httpd-php .php

在DirectoryIndex指令的最后,添加 index.php

測試Apache及php支持

apache 的控制文件在 /usr/local/apache2/bin 下

apachectl stop 停止apache 服務

apachectl start 啟動apache 服務

自行完成一個php 測試頁1.php, 包含一行:

<? phpinfo() ?> ,放在DocumentRoot下

[root@localhost discuz]# chown -R daemon.daemon /usr/local/apache2/htdocs/ucenter daemon是apache的系統(tǒng)用戶

農場

cd /var/ftp/mysql/bbs/sns/

unzip farm-ucenter1.5.zip

mv upload/ /usr/local/apache2/htdocs/farm

http://172.16.110.1/farm/install/index.php

chmod -R 777 /usr/local/apache2/htdocs/farm/

數(shù)據(jù)庫服務器:localhost

數(shù)據(jù)庫名:farm

數(shù)據(jù)庫用戶名:root

數(shù)據(jù)庫密碼:

UCenter 創(chuàng)始人密碼:123重復密碼:123

管理員帳號:admin

管理員密碼:123

重復密碼:123

管理員 Email:admin@admin.com

解決:MySQL Error: 1146.

[root@robin farm]# cd /usr/local/apache2/htdocs/farm/

mysql -u root farm < /usr/local/apache2/htdocs/farm/qqfarm.sql

rpm -ivh /var/ftp/mysql/bbs/flash-plugin-11.1.102.62-release.i386.rpm

筆記補充:

非關系型數(shù)據(jù)庫 nosql

關系型數(shù)據(jù)庫 mysql oracle

每個單元格為: 字段 每行為: 記錄 每列為: 列

mysql的root帳號跟系統(tǒng)root帳號沒關系

information_schema 內存

performance_schema 優(yōu)化

\c 命令不執(zhí)行 ctrl + c 退出mysql

\G文本格式顯示

默認數(shù)據(jù)類型帶符號,比如tinyint(-128,127)

插入數(shù)據(jù)時斋泄,字符串用單引號擴起來杯瞻。

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市是己,隨后出現(xiàn)的幾起案子又兵,更是在濱河造成了極大的恐慌,老刑警劉巖卒废,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件沛厨,死亡現(xiàn)場離奇詭異,居然都是意外死亡摔认,警方通過查閱死者的電腦和手機逆皮,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來参袱,“玉大人电谣,你說我怎么就攤上這事秽梅。” “怎么了剿牺?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵企垦,是天一觀的道長。 經常有香客問我晒来,道長钞诡,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任湃崩,我火速辦了婚禮荧降,結果婚禮上,老公的妹妹穿的比我還像新娘攒读。我一直安慰自己朵诫,他們只是感情好,可當我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布薄扁。 她就那樣靜靜地躺著剪返,像睡著了一般。 火紅的嫁衣襯著肌膚如雪泌辫。 梳的紋絲不亂的頭發(fā)上随夸,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天,我揣著相機與錄音震放,去河邊找鬼。 笑死驼修,一個胖子當著我的面吹牛殿遂,可吹牛的內容都是我干的。 我是一名探鬼主播乙各,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼墨礁,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了耳峦?” 一聲冷哼從身側響起恩静,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎蹲坷,沒想到半個月后驶乾,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡循签,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年级乐,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片县匠。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡风科,死狀恐怖撒轮,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情贼穆,我是刑警寧澤题山,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站故痊,受9級特大地震影響臀蛛,放射性物質發(fā)生泄漏。R本人自食惡果不足惜崖蜜,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一浊仆、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧豫领,春花似錦抡柿、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至课蔬,卻和暖如春囱稽,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背二跋。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工战惊, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人扎即。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓吞获,卻偏偏與公主長得像,于是被迫代替她去往敵國和親谚鄙。 傳聞我的和親對象是個殘疾皇子各拷,可洞房花燭夜當晚...
    茶點故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內容