Allow all remote connections, MySQL

前端 未结 7 1462
予麋鹿
予麋鹿 2020-11-28 01:34

I had been using SQL Server and am now using MySQL for a project. With SQL Server, our developers can connect to the remote database on their local machines if they know the

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 02:10

    Install and setup mysql to connect from anywhere remotely DOES NOT WORK WITH mysql_secure_installation ! (https://dev.mysql.com/doc/refman/5.5/en/mysql-secure-installation.html)

    On Ubuntu, Install mysql using:

    sudo apt-get install mysql-server
    

    Have just the below in /etc/mysql/my.cnf

    [mysqld]
    #### Unix socket settings (making localhost work)
    user            = mysql
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    
    #### TCP Socket settings (making all remote logins work)
    port            = 3306
    bind-address = 0.0.0.0
    

    Login into DB from server using

    mysql -u root -p

    Create DB user using the below statement

    grant all privileges on *.* to ‘username’@‘%’ identified by ‘password’;
    

    Open firewall:

    sudo ufw allow 3306
    

    Restart mysql

    sudo service mysql restart
    

提交回复
热议问题