Posts Tagged ‘mysql’

MySQL table copy

Sunday, September 6th, 2009

If you want to duplicate a MySQL table (with data), you can do:

mysql> CREATE TABLE tmpscores LIKE scores;
Query OK, 0 rows affected (0.00 sec)
 
mysql> INSERT INTO tmpscores SELECT * from scores;
Query OK, 116 rows affected (0.02 sec)
Records: 116  Duplicates: 0  Warnings: 0
 
mysql>

Alternatively, you can do this in one step:

mysql> CREATE TABLE tmpscores SELECT * FROM scores;
Query OK, 116 rows affected (0.02 sec)
Records: 116  Duplicates: 0  Warnings: 0
 
mysql>

Note that the first method does create indexes for you while the second doesn’t (see here).

Running a syntax check on /etc/my.cnf

Thursday, October 9th, 2008

Usually, I update variables on the fly using something like:

mysql> SET GLOBAL max_connections = 150;

… and then modify /etc/my.cnf to make the change persistent.

The problem in doing this is that you’re not verifying that your /etc/my.cnf is correct and can only hope that a restart doesn’t encounter any problems.

Fortunately, Sai emailed us a great little tip to verify the syntax. You can run the following which will report errors in /etc/my.cnf:

# /usr/libexec/mysqld --help --verbose
081009  9:55:36 [ERROR] /usr/libexec/mysqld: unknown variable 'mmax_connections=150'
 
#

Perfect. Just what the doctor ordered.

postfix + MySQL support on RHEL 5

Friday, July 18th, 2008

If you’re running RHEL 5 and need postfix built w/ MySQL support, you can use the CentOSPlus Repository package found here. This is not an ideal solution as it’s not a Red Hat package but would save you having to rebuild Red Hat’s source package to get MySQL support. More information this repository can be found here.

Edit: Numerous people have requested that Red Hat add MySQL support to postfix in this Red Hat bugzilla bug, but it seems Red Hat are reluctant to add the support as it’d add an extra dependancy to postfix. People have stated that the same dependancy already exists for dovecot so I’m not sure what the holdup is.

vsftpd w/ MySQL users on CentOS 5.2

Monday, July 7th, 2008

Although not written for CentOS, I used this which worked pretty well. The only issue I had was that my /etc/my.cnf contained old_passwords=1 and it was looking for the new password scheme when configuring /etc/pam.d/vsftpd with crypt=2 (mysql). Setting the password in the accounts table using md5(‘something’) and then changing crypt=3 in /etc/pam.d/vsftpd also seemed to work fine.

As for pam_mysql.so, this isn’t provided by Red Hat for CentOS / RHEL 5 so I had to grab a package from here.