What is the MySQL Equivalent of SQL CE? - mysql

I'd like to know if WordPress can be pointed at the DB equivalent of SQL CE. I presume the answer is yes, if MySQL has something equivalent to SQL CE.
What's the low down on this?
Update: Given the answers so far, I will re-state my question so that it is more easily understood: "Can WordPress be pointed at SQLite instead of MySQL?"

I'd like to know if WordPress can be pointed at the DB equivalent of SQL CE
No.
Or at least not easily. WordPress is built on top the LAMP stack where M is strictly MySQL. Although it has a database abstraction layer (WPDB), the code and plugins are littered and accept direct SQL code (MySQL).
If you are interested in this, check out the discussion in the WP Codex.
What is the MySQL Equivalent of SQL CE?
In my opinion, I'd make the jump and say SQLite.

As far as I'm aware there is no MySQL equivalent of SQL Compact Edition. You may want to check SQLite instead (www.sqlite.org). Wordpress supports this.

You may find this surprising but MySQL can be stripped down to operate like a Compact Edition database. MySQL (eh Oracle) does not seem to support the Embedded MySQL anymore (or at least they make hard to find). However, you can make the following tweeks to MySQL:
TWEEK #1 : Disable InnoDB
Start mysqld with this in my.cnf:
[mysqld]
skip-innodb
Benefits
Faster startup of mysql
Does not create ibdata1, ib_logfile0, ib_logfile1
Does not allocate default InnoDB Buffer Pool (MySQL 5.5 128M, before MySQL 5.5 8MB)
Less memory consumption (InnoDB code is not memory resident)
TWEEK #2 : Preload Indexes of the Most Important MyISAM Tables
By default, MyISAM uses the Key Cache and its size is governed by key_buffer_Size. Interestingly, MyISAM allows you to create a dedicate key cache for onr ot more tables.
For example, if you have the table mysite.wp_posts, you can create a dedicated 256M key cache as follows:
SET GLOBAL wp_posts_cache.key_buffer_size = 1024 * 1024 * 256;
CACHE INDEX mysite.wp_posts IN wp_posts_cache;
LOAD INDEX INTO CACHE mysite.wp_posts;
You can have this done at start by doing this:
echo "SET GLOBAL wp_posts_cache.key_buffer_size = 1024 * 1024 * 256;" > /var/lib/mysql/startup.sql
echo "CACHE INDEX mysite.wp_posts IN wp_posts_cache;" > /var/lib/mysql/startup.sql
echo "LOAD INDEX INTO CACHE mysite.wp_posts;" > /var/lib/mysql/startup.sql
Give it a Try !!!
then add this to my.cnf
[mysqld]
init-file=/var/lib/mysql/startup.sql
Then, restart mysql

Related

MySQL my.cnf config setup for MyISAM

I currently have a Cloud based server with the following config.
CentOS 7 64-Bit
CPU:8 vCore
RAM:16 GB
MariaDB/MySQL 5.5.5
Unfortunately, I've inherited a MyISAM database and tables that I have no control to convert to INNODB even though the application performs many writes from many connections. The data is Wordpress Posts with the typical large text and photos.
I'm experimenting with my.cnf config changes and was wondering if the config I've developed here is making use of the resources in the most effecient way. Is there anything glaring I could increase/decrease to squeak out more performance?
key_buffer_size=4G
thread_cache_size = 128
bulk_insert_buffer_size=256M
join_buffer_size=64M
max_allowed_packet=128M
query_cache_limit=128M
read_buffer_size=16M
read_rnd_buffer_size=16M
sort_buffer_size=16M
table_cache=128
tmp_table_size=128M
This will depend entirely on the type of data you are storing, the structure and size of your tables and the type of usage your database has. Not to mention the amount of available RAM and the type of disks your server has.
The best recommendation, if you have shell access to the server (which I assume you must, otherwise you couldn't change my.cnf) is to download the mysqltuner script from major.io
Run this script as a user with privileges to access your database, and preferably with root privileges on mysql too (the ideal is to run it under sudo or root) and it will analyse your database access since mysql's last restart, and then give you recommendations to change the options in my.cnf
It isn't perfect, but it'll get you much further, and more quickly, than anyone on here trying guess what values would be appropriate for your use case.
And, while not trying to pre-empt the results, I wouldn't be surprised if mysqltuner recommends that you drastically increase the size of your join buffer, table_cache and query_cache_limit.

mysql 5.6 Linux vs windows performance

The below command takes 2-3 seconds in a Linux MySQL 5.6 server running Php 5.4
exec("mysql --host=$db_host --user=$db_user --password=$db_password $db_name < $sql_file");
On windows with similar configuration it takes 10-15 seconds. The windows machine has a lot more ram (16gb) and similar hard drive. I installed MySQL 5.6 and made no configuration changes. This is on windows server 2012.
What are configurations I can change to fix this?
The database file creates about 40 innodb tables with very minimal inserts.
EDIT: Here is the file I am running:
https://www.dropbox.com/s/uguzgbbnyghok0o/database_14.4.sql?dl=0
UPDATE: On windows 8 and 7 it was 3 seconds. But on windows server 2012 it is 15+ seconds. I disabled System center 2012 and that made no difference.
UPDATE 2:
I also tried killing almost every service except for mysql and IIS and it still performed slowly. Is there something in windows server 2012 that causes this to be slow?
Update 3
I tried disable write cache buffer flush and performance is now great.
I didn't have to do this on other machines I tested with. Does this indicate a bottleneck With how disk is setup?
https://social.technet.microsoft.com/Forums/windows/en-US/282ea0fc-fba7-4474-83d5-f9bbce0e52ea/major-disk-speed-improvement-disable-write-cache-buffer-flushing?forum=w7itproperf
That is why we call it LAMP stack and no doubt why it is so popular mysql on windows vs Linux. But that has more to do more with stability and safety. Performance wise the difference should be minimal. While a Microsoft Professional can best tune the Windows Server explicitly for MySQL by enabling and disabling the services, but we would rather be interested to see the configuration of your my.ini. So what could be the contributing factors w.r.t Windows on MySQL that we should consider
The services and policies in Windows is sometimes a big impediment to performance because of all sorts of restrictions and protections.
We should also take into account the Apache(httpd.conf) and PHP(php.ini) configuration as MySQL is so tightly coupled with them.
Antivirus : Better disable this when benchmarking about performance
Must consider these parameters in my.ini as here you have 40 Innodb tables
innodb_buffer_pool_size, innodb_flush_log_at_trx_commit, query_cache_size, innodb_flush_method, innodb_log_file_size, innodb_file_per_table
For example: If file size of ib_logfile0 = 524288000, Then
524288000/1048576 = 500, Hence innodb_log_file_size should be 500M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
https://dev.mysql.com/doc/refman/5.1/en/innodb-tuning.html
When importing data into InnoDB, make sure that MySQL does not have autocommit mode enabled because that requires a log flush to disk for every insert
SET autocommit=0;
Most importantly innodb_flush_log_at_trx_commit as in this case it is about importing database. Setting this to '2' form '1' (default)hm can be a big performance booster specially during data import as log buffer will be flushed to OS file cache on every transaction commit
For reference :
https://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html
https://dba.stackexchange.com/a/72766/60318
http://kvz.io/blog/2009/03/31/improve-mysql-insert-performance/
Lastly, based on this
mysql --host=$db_host --user=$db_user --password=$db_password $db_name < $sql_file
If the mysqldump (.sql) file is not residing in the same host where you are importing, performance will be slow. Consider to copy the (.sql) file exactly in the server where you need to import the database, then try importing without --host option.
Windows is slower at creating files, period. 40 InnoDB tables involves 40 or 80 file creations. Since they are small InnoDB tables, you may as well set innodb_file_per_table=OFF before doing the CREATEs, thereby needing only 40 file creations.
Good practice in MySQL is to create tables once, and not be creating/dropping tables frequently. If your application is designed to do lots of CREATEs, we should focus on that. (Note that, even on Linux, table create time is non-trivial.)
If these are temporary tables... 5.7 will have significant changes that will improve the performance (on either OS) in this area. 5.7 is on the cusp of being GA.
(RAM size is irrelevant in this situation.)

Enable InnoDB in MySQL

I want to use foreign key in MySQL. For that I needed to enable InnoDB feature. I have tried downloading latest version of MySQL Server from its official site.
I went through similar questions on stackoverflow but they addressed different issues.
I have tried editing all the .ini files and enabling InnoDB properties by removing # in front of corresponding properties.
Then I restarted MySQL and checked status of InnoDB from MySQL Client using query/
show engines;
It still shows InnoDB is disabled
I want to know steps of enabling the built in InnoDB feature for MySQL.
Here are the links to questions I visited:
Ques1
Ques2
Official MySQL forum
I am newbie in MySQL.
I will be very thankful for any help :-)
Check mysql log file. There could be some messages that may explain why InnoDB does not start. I suppose you don't have important InnoDB data. If so, try deleting ib_logfile0.xxx files and ibdata located in mysql data dir, then restart mysql to force those file to recreate. Also, check if innodb variables in my.cnf are properly configurated (For example, I have set memory for innodb_pool... to 1024G instead of 1024M, as a mistake).

MySQL - what does skip-locking in my.cnf do?

I'm using MySQL 5.0.67 on RHEL5 and basing my configuration on my-huge.cnf.
I can't find anything in the MySQL manual for the row 'skip-locking' which appears in the config file.
Should this be replaced with 'skip_external_locking' or should I just remove the row entirely as that is now a default.
MySQL Manual for skip-external-locking
Thanks.
see http://dev.mysql.com/doc/refman/5.0/en/external-locking.html
quote:
If you run multiple servers that use the same database directory (not recommended), each server must have external locking enabled.
It really just has to do with the dangers presented by multiple processes accessing the same data. In many DBMS situations you want to lock the table/row before performing an operation, and unlocking afterwards. This is to prevent possible data corruption.
Edit: see http://dev.mysql.com/doc/refman/4.1/en/news-4-0-3.html
Quote
Renamed --skip-locking to --skip-external-locking.
An additional note for anyone who doesn't follow the link provided by #Jonathan Fingland :
8.7.4. External Locking
This option only applies to MyISAM tables.
As Richard indicated, external locking is disabled by default. You need to enable external locking if you use myisamchk for write operations or if you use myisampack to pack tables.
From the docs:
If you use myisamchk to perform table maintenance operations on MyISAM
tables, you must either ensure that the server is not running, or that
the server has external locking enabled so that it locks table files
as necessary to coordinate with myisamchk for access to the tables.
The same is true for use of myisampack to pack MyISAM tables.
If you use myisamchk for write operations such as repairing or
optimizing tables, or if you use myisampack to pack tables, you must
always ensure that the mysqld server is not using the table. If you
don't stop mysqld, you should at least do a mysqladmin flush-tables
before you run myisamchk. Your tables may become corrupted if the
server and myisamchk access the tables simultaneously.

How to change bdb cache size in mysql?

I would like to change variable bdb cache size (bdb_cache_size) on my mysql database to be able to import bigger SQL files (yes, i've set all other variables for example in php.ini to higher values and it does not work) in phpmyadmin.
How can I do that?
If you're really using BDB in your MySQL database, check you don't have skip-bdb in your my.cnf. Most installations disable it (and disable it this way) by default.
Berkeley DB is going away very soon in MySQL, so if you're using it, I'd recommend you shift to InnoDB (or at the very least MyISAM).