天天看點

親測小白系列之-mysql安裝,遠端通路

  • mac mysql安裝

    brew install mysql

    mysql.server start

    use mysql

    select host,user,plugin,authentication_string from user;

    update user set host = '%' where user = 'root';

    FLUSH PRIVILEGES;

    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';

    netstat -an|grep 3306

    修改/etc/mysql/my.cnf檔案,brew修改/usr/local/etc/my.cnf

    注釋bind-address = 127.0.0.1

    vi /usr/local/etc/my.cnf

    mysql.server restart

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;

    mac中老是報錯,留作備忘
  • 遠端思路

    1.看清報錯提示,不要盲目

    2.檢視root使用者host,以及加密方式

    3.檢視mysql監聽,修改配置檔案綁定本地和防火牆

  • linux 安裝
    wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
    rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum install mysql-community-server
    service mysqld restart
               

    初次安裝mysql,root賬戶沒有密碼

    設定密碼

    set password for 'root'@'localhost' =password('password');

  • 配置mysql 編碼 遠端

    mysql配置檔案為/etc/my.cnf

    最後加上編碼配置

    default-character-set =utf8

    遠端通路指令

    grant all privileges on *.* to root@'%'identified by 'password';

  • 修改密碼新老版本5.7
    use mysql;
    update user set password=password('123') where user="root";
    update user set authentication_string=password('123') where user="root";
    flush privileges;
               
  • 忘記密碼

    1.檢查mysql啟動

    ps -ef | grep -i mysql

    2.關閉

    service mysql stop

    3.my.cnf配置檔案的位置,一般在/etc/my.cnf,有些版本在/etc/mysql/my.cnf,配置檔案中,增加2行代碼
    [mysqld]
    skip-grant-tables
               
    4.啟動

    service mysqld start

    5.進入

    mysql -u root

    6.修改密碼

    7.删除增加的配置,重新開機