MySQL – Can I help? https://lemuel.leung.us Lemuel Leung | Hosting Consultant Tue, 18 Feb 2020 17:22:21 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://lemuel.leung.us/wp-content/uploads/2019/06/cropped-lemico-32x32.png MySQL – Can I help? https://lemuel.leung.us 32 32 WordPress/MySQL change URLs https://lemuel.leung.us/wordpress-mysql-change-urls/ https://lemuel.leung.us/wordpress-mysql-change-urls/#respond Tue, 18 Feb 2020 17:22:20 +0000 https://lemuel.leung.us/?p=552 ; SHOW TABLES; Grab site URLs SELECT * FROM wp_options WHERE option_name = 'home'; SELECT * FROM wp_options WHERE option_name = 'siteurl'; **NOTE** Multisite setups are different. Each site has their own set of wp_options, depending on your site, it may be set Read more about WordPress/MySQL change URLs[…]]]> Connect to MySQL and view tables to see what you need

USE <DB_NAME>;
SHOW TABLES;

Grab site URLs

SELECT * FROM wp_options WHERE option_name = 'home';
SELECT * FROM wp_options WHERE option_name = 'siteurl';

**NOTE** Multisite setups are different.  Each site has their own set of wp_options, depending on your site, it may be set to different numbers.  Typically, it will be wp_2_options, wp_3_options, etc.

Replace values with what you want

UPDATE wp_options SET option_value="http://new_host/wordpress" WHERE option_name = "home";
UPDATE wp_options SET option_value="http://new_host/wordpress" WHERE option_name = "siteurl";

**NOTE** For multisite setups, make sure your wp_options match the number for the site in question.  
]]>
https://lemuel.leung.us/wordpress-mysql-change-urls/feed/ 0
WordPress can’t connect to database after MySQL move to new datadir https://lemuel.leung.us/wordpress-cant-connect-to-database-after-mysql-move-to-new-datadir/ https://lemuel.leung.us/wordpress-cant-connect-to-database-after-mysql-move-to-new-datadir/#respond Mon, 09 Dec 2019 09:48:14 +0000 https://lemuel.leung.us/?p=536 Read more about WordPress can’t connect to database after MySQL move to new datadir[…]]]> Resolution:
The problem is related to your moving the mysql.sock file to a new location. PHP needs to know where it is, changing the location will fix the problem and reload apache/httpd (if you are using php-fpm, restart the service)

Easy fix: Edit your php.ini file and make sure you specify the new mysql.sock location.

mysqli.default_socket = /path/to/your/files/mysql.sock

Issue: After moving your datadir for MySQL, WordPress will still not pull up and present the “Error connecting to the database” error.

RELATED ARTICLE(S):

1. Moving mysql datadir in Redhat (don’t forget SELinux!)
2. WordPress troubleshooting

]]>
https://lemuel.leung.us/wordpress-cant-connect-to-database-after-mysql-move-to-new-datadir/feed/ 0
Moving mysql datadir in Redhat (don’t forget SELinux!) https://lemuel.leung.us/moving-mysql-datadir-in-redhat-dont-forget-selinux/ https://lemuel.leung.us/moving-mysql-datadir-in-redhat-dont-forget-selinux/#respond Mon, 09 Dec 2019 09:37:50 +0000 https://lemuel.leung.us/?p=533 Read more about Moving mysql datadir in Redhat (don’t forget SELinux!)[…]]]> Issue: You have moved /var/lib/mysql data files to their new destinations, but mysql will not start up.

Resolution(s):

1. Review and verify configurations

       (in this example, MySQL 8)
- /etc/my.cnf.d/mysql-server.cnf
datadir=/ & socket=/ set to the right folder?
- /etc/my.cnf.d/client.cnf
add the following lines under [client]:
datadir=/path/to/your/files
port=3306

2. Grant SELinux permissions to the new folder

Run the following commands to change the datadir
#semanage fcontext -a -t mysqld_db_t "/path/to/your/files(/.*)?"
# restorecon -Rv /path/to/your/files

Run the following commands to change the mysql.sock file
# semanage fcontext -a -t mysqld_var_run_t "/path/to/your/files/mysql.sock"
# restorecon -Rv /path/to/your/files/mysql.sock 

RELATED ARTICLES(S)

After moving the above and restarting MySQL successfully, WordPress still would not load.

See the following article for help with troubleshooting WordPress: click here
See the following article for making sure PHP is configured correctly: click here

]]>
https://lemuel.leung.us/moving-mysql-datadir-in-redhat-dont-forget-selinux/feed/ 0
Connection errors from WordPress to Azure MySQL database https://lemuel.leung.us/connection-errors-from-wordpress-to-azure-mysql-database/ https://lemuel.leung.us/connection-errors-from-wordpress-to-azure-mysql-database/#respond Thu, 31 Oct 2019 06:35:23 +0000 https://lemuel.leung.us/?p=504 Read more about Connection errors from WordPress to Azure MySQL database[…]]]> Issue: You are getting connection issues to your hosted Azure MySQL database server. You are putting the correct information in, but still WordPress is showing Error Connecting to Database.

Error: After some investigation, you most likely are getting this error:

mysqli_real_connect(): (HY000/9002): SSL connection is required. Please specify SSL options and retry

Resolution: Believe it or not, this is a simple one. Azure REQUIRES that your connection to the database uses SSL.

Simply put the following line in your wp-config.php file and all will be well. I typically include a description for my own reference

/** Secure Connection to Azure MySQL db */
define(‘MYSQL_CLIENT_FLAGS’, MYSQLI_CLIENT_SSL);

]]>
https://lemuel.leung.us/connection-errors-from-wordpress-to-azure-mysql-database/feed/ 0
MySQL Cheat Sheet https://lemuel.leung.us/mysql-cheat-sheet/ https://lemuel.leung.us/mysql-cheat-sheet/#respond Sun, 22 Feb 2015 04:38:42 +0000 https://lemuel.leung.us/?p=272 Read more about MySQL Cheat Sheet[…]]]> I grew accustomed to using MySQL GUI tools, but found that they can be quite daunting to use, ESPECIALLY a big pain to use is the MySQL Workbench suite.  If you MUST use a GUI interface, try SQLYog.  Simple and to the point.

If you are looking for MySQL command line, here are a few that may come in handy:

Database commands

  • create database ‘databasename’;
  • drop database ‘databasename’;
  • show databases;
  • use ‘databasename’

Backing up databases

  • mysqldump -u username -p ‘databasename’ > dumpfile.sql

Restoring databases

  • 1st option (from MySQL path):  mysqldump -u username -p ‘databasename’ < dumpfile.sql
  • 2nd option (from MySQL prompt):
    • use ‘databasename’
    • source ‘pathtodumpfile.sql’;

Create and Permissioning

  • Show all users: SELECT User, Host, Password FROM mysql.user;
  • SHOW GRANTS [FOR user]
  • GRANT ALL ON databasename.* to ‘databasename’@’localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
  • NOTE:  With any user changes, ALWAYS run:  FLUSH PRIVILEGES; (this will force the changes to go into effect)
]]>
https://lemuel.leung.us/mysql-cheat-sheet/feed/ 0
Migrate WordPress.com site https://lemuel.leung.us/migrate-wordpress-com-site/ https://lemuel.leung.us/migrate-wordpress-com-site/#respond Sat, 29 Jun 2013 14:43:32 +0000 https://lemuel.leung.us/?p=176 Read more about Migrate WordPress.com site[…]]]> Issue:  Client wanted to migrate their WordPress.com site and retain full functionality in a WordPress.org site.

Long/Short:  This is not possible to do, as the WordPress.com sites have built-in features exclusive to only WordPress’ own hosting platform.  Note in the article that you can only use Tools/Export to an XML file (or, of course, pay $129 and they will export everything for you).  When you do this, it only exports posts, pages, comments, categories, and tags.  It DOES NOT migrate your existing media uploads and images; these, you will have to migrate manually.  

Read more (from WordPress.com):  http://en.support.wordpress.com/export/

Resolution:  Export the XML file and import into your WordPress.org site as mentioned. If you have access to the MySQL backend, export the MySQL database to a .sql file, edit it and rename all the links to the new domain.  Download each file from the media library and import it into the new instance.  Remember to change the links to point to the right media file.

Problems:  Remember previous features may not be available, even if you use the same theme.  The themes they provide are customized and made easier for users.  If you need further help (design related), then you will need to find an experienced developer who can edit themes and customize it to your liking.

]]>
https://lemuel.leung.us/migrate-wordpress-com-site/feed/ 0