LAMP--mysql 基本配置

來源:互聯網
上載者:User

標籤:mysql 常用操作;lamp--mysql 恢複root密碼


重設ROOT密碼:


1. 編輯mysql主設定檔 my.cnf
vim /etc/my.cnf  
在[mysqld]欄位下添加參數  skip-grant  
2. 重啟資料庫服務
service mysqld restart
3. 這樣就可以進入資料庫不用授權了
mysql -uroot 
4. 修改相應使用者密碼
use mysql;
update user set password=password(‘your password‘) where user=‘root‘;
flush privileges;

//‘your password‘    新的 密碼    (使用 單引號)
5.  修改/etc/my.cnf 去掉 skip-grant , 重啟mysql服務


mysql常用操作.
遠程登入 mysql      mysql -uroot  -h12.7.0.0.1(61.181.24.12) -P3306  -p1234
                                                              連接埠     目標IP               
  mysql -uroot -S /tmp/mysql.sock   -p123
          指定sock 只在本地使用
grant all on              *.*    to ‘root‘@‘192.168.0.153‘ identified by ‘123456‘
     所有許可權      所有庫、表             來源IP 可以使用 % 表示所有IP
flush privileges
          重新整理許可權
     調用系統命令  system +xx(ls..)
查看都有哪些庫  show databases;
查看某個庫的表 use discuz(庫明);     //使用庫
                         show tables;          //查看錶

查看錶的欄位      desc     表名;
查看建表語句      show create table  表名;

當前是哪個使用者  select user();
當前庫 select database();
建立庫 create database 庫名;
建立表 create table t1 (`id` int(4), `name` char(40));
查看錶 show create table t1\G
T1表中插入     insert into t1 values(1, ‘onda‘);
只插入ID      insert into t1 (`id`) values(2);
只插入 NAME   insert into t1 (`name`) values (‘123‘);       
                        t1 為表名


查看錶項目類型 show  columns from  表名;
查看資料庫版本 select version();
查看mysql狀態 show status;


更新一行    update db1.t1 set name=‘aaa‘ where id=1;
刪除一行     delete from t1 where id=3;

清空表(清空表中內容) truncate table db1.t1;

刪除表 drop table db1.t1;
刪除資料庫 drop database db1;


查看mysql任務隊列 show processlist;
全部      show full processlist;


修改mysql參數 show variables like ‘max_connect%‘;
               最大串連數           %表示通配
show variables like ‘%timeout‘;
    查看 匹配timeout 的內容
要更改  參數   就寫在 linux 設定檔裡  /etc/my.cnf
  vim /etc/my.cnf    修改配置
wait_timeout=8
interactive_timeout=8     這倆個必須一起用
/etc/init.d/mysqld restart  重啟
寫入 /etc/my.cnf 是 寫在磁碟中 (重啟後生效) 

show variables like ‘%timeout‘; 查看 已經改變

set global connect_timeout = 1000;
             參數             賦值
這樣是寫在緩衝中(不重啟更改參數)
         

查看 發表文章 的表
select * from pre_forum_post\G;
     subject 標題
     message 內容
     useip  來源ip

select *from pre_forum_post where subject like ‘%111%‘\G;
   查看  文章    標題 進行模糊比對 ‘111‘


本文出自 “你我同行” 部落格,請務必保留此出處http://ondali.blog.51cto.com/6650368/1613933

LAMP--mysql 基本配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.