MariaDB > grant all privileges on *.* to identified by 'strongpass' In case of remote connection to MySQL database, the root user must be explicitly configured to allow incoming connections form all networks or just an IP address, by issuing the below command in MySQL console: # mysql -u root -p But the TCP port number must be explicitly specified in case of command line remote connections to MySQL database using the -P flag. However, be aware that all connections to MySQL on localhost are made via MySQL unix domain socket, not via the TCP socket. You can also display the new MySQL port by logging in to MySQL database with root account and issue the below command. In order to verify if the port configuration for MySQL/MariaDB database server has been successfully applied, issue netstat or ss command and filter the results via grep command in order to easily identify the new MySQL port. # semanage port -a -t mysqld_port_t -p tcp 12345 Again, replace MySQL port variable to match your own port number. Next, add the below SELinux rule to bind MySQL socket on the new port and restart the database daemon to apply changes, by issuing the following commands. Īfter you’ve added the new MySQL/MariaDB port, save and close the configuration file and install the following package under CentOS 7 in order to apply the required SELinux rules to allow the database to bind on the new port. Search for the line stat starts with and place the following port directive under statement, as shown in the below file excerpts. In order to change the default MySQL/MariaDB database port in Linux, open MySQL server configuration file for editing by issuing the below command. The default port that MySQL database server is running under Linux and Unix is 3306/TCP. If you are trying to restore a single database from dump of all the databases, you have to let mysql know like this: mysql -one-database database_name < all_databases.In this guide we’ll learn how to change the default port that MySQL/MariaDB database binds in CentOS 7 and Debian-based Linux distributions. In the code above, database_name is the name of the database you want to restore, and database_name.sql is the name of the backup file to be restored. Since the dump files are just SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data into the proper database. After reinstalling with the desired port number. It is also simple to back up all of the databases on a server: mysqldump -all-databases > all_databases.sqlĪfter taking the backup, remove mysql and reinstall it. In the code above, database_one is the name of the first database to be backed up, and database_two is the name of the second. Multiple databases can be backed up at the same time: mysqldump -databases database_one database_two > two_databases.sql If you want to back up a single database, you merely create the dump and send the output into a file, like so: mysqldump database_name > database_name.sql These dumps are just files with all the SQL commands needed to recreate the database from scratch. The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. The best way to do this is take backup of required database and reconfigure the server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |