How do I create a database on MariaDB server? - mariadb

My hosting provider shows Server version: 10.1.44-MariaDB-cll-lve - MariaDB Server on cPanel.
I'm about to do some dev work locally.
I installed MariaDB on my Windows 10. It went under C:\Program Files\MariaDB 10.4 and I see that it installed itself as a service called MariaDB. Service is running.
I'm asking my question after trying a whole whack of things because I had done this many times using MySQL before this MariaDB thing.
How do I create a database off an sql dump file?
Since nothing that I'm trying is working and this is a brand new Maria DB installation , I would rather not talk about how I did this before. Instead, having this MariaDB installation now, what do I do to import this sql file?

OK, so this is what we need to do:
Assuming that your database is called MyDB.
Start command prompt as admin.
cd C:\Program Files\MariaDB 10.4\bin> // /bin where your MariaDB installation went.
mysql -u root
create database MyDB;
exit;
mysql -uroot MyDB < C:/where-you-have-the-file/dump-file.sql
mysql -u root
use MyDB
show tables;
Hopefully, you see your schema.

Related

Load SQLite extensions in SchemaCrawler

My SQLite database has a virtual table that is created by using the spelfix1.dll extention.
Is there any solution to load this extention in schemacrawler?
When I try to create the graphic with
schemacrawler --server=sqlite --database=/home/schcrwlr/share/database.db --info-level=minimum --command=list --output-file=/home/schcrwlr/share/output.png
after starting the container with
C:\Users\user> docker run `
-v ${PWD}:/home/schcrwlr/share `
--name schemacrawler `
--rm -i -t `
--entrypoint=/bin/bash `
schemacrawler/schemacrawler:v16.16.6
Schemacrawler execution stop because the extenion is missing according to the log-files
Caused by: schemacrawler.schemacrawler.exceptions.WrappedSQLException: Could not retrieve table columns for table <lang_store>: [SQLITE_ERROR] SQL error or missing database (no such module: spellfix1)
and
Caused by: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such module: spellfix1)
I work in the Windows PowerShell on Win10.
Environment:
SchemaCrawler 16.16.6
Linux 5.10.16.3-microsoft-standard-WSL2
Oracle Corporation OpenJDK 64-Bit Server VM 17-ea+14
SQLite 3.36.0
SQLite JDBC 3.36.0.3
This is more a question about the SQLite JDBC driver than about SchemaCrawler. The SchemaCrawler Docker image comes bundled with SQLite JDBC driver and does not allow for reading of external extension libraries for security reasons. If you really wanted to do this, you would have to use the regular distribution of SchemaCrawler and provide the extension DLL file in the lib folder. Or you could build your own Docker image with this extension, based on the SchemaCrawler Docker image. All of this seems like too much work.
Your best bet is the strip the schema of the virtual tables and run SchemaCrawler again. Please take a look at the procedure for doing this in the answer to Reflecting sqlite database with spellfix1 tables
Sualeh Fatehi, SchemaCrawler

MariaDB installer on Linux changing the custom db file ownership to default mysql and causing database to go down

When I run sudo apt upgrade, the MariaDB package installer will attempt to upgrade MariaDB but it'll change the database file ownership to default user 'mysql'. Since the file ownership got changed, MariaDB will fail to restart.
I've several servers configured with the same setup, but this problem is only seen in a few of them. I don't know how to configure the installer so that it does not change the file owner to default mysql.
Environment:
Linux Ubuntu 18 LTS
MariaDB 10.3
MariaDB setup:
Configured MariaDB to run as 'mydbuser' rather than the default 'mysql'.
Intalled dbfiles in /mydir/mariadb/.
File and dir ownership from /mydir/mariadb/ is set to mydbuser:mydbgroup.

Migrate a self-hosted wordpress to MS Azure. Max query threshold exceeded with ClearDB

I would like to migrate a self-hosted wordpress site to Microsoft Azure. I've already done this migration job with Duplicator plugin from a server to another and everything worked well.
The problem with Ms Azure is that it uses a service called ClearDB to manage databases. (feel free to correct me if it's wrong) When you create a free account with this service you will get a restricted plan called Mercury which allows you to query your db (max dimension of 20MB) up to 3600 queries/hour.
But the migration process requires several operations on the database and the
As written in this blog the only option is to upgrade your plan to the 10$/month subscription.
I've found another way but the plugin the author uses in this link does not work for me.
Should I use another plugin to backup my WP content?
Do you have any advice?
Thanks
There are three solutions. I chose the first one.
Configure Mysql on a virtual machine and install Wordpress (classic way)
This can be done installing an already configured image with the Lamp packages on your Virtual Machine. Please see this link
If you want to set up it manually, follow these steps:
Create the vm (I used Ubuntu 14.04) then connect via SSH to your server.
ssh root#server_ip_address
Install Apache
sudo apt-get update
sudo apt-get install apache2
To check if Apache is installed, direct your browser to your server’s IP address. The page should display the words “It works!"
Install MySQL
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During the installation, MySQL will ask you to set a root password. Once you have installed MySQL activate it with this command:
sudo mysql_install_db
Finish up by running the MySQL set up script:
sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password.
Install PHP
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
PHP also has a variety of useful libraries and modules that you can add onto your virtual machine. You can see the libraries that are available.
apt-cache search php5-
Decide which module you wish to install and type:
sudo apt-get install name_of_the_module
Although LAMP is installed, we can still take a look and see the components online by creating a quick php info page. Create a new file:
sudo nano /var/www/info.php
Add in the following line. Save and exit
<?php
phpinfo();
?>
Finally restart apache
sudo service apache2 restart
and check the info page typing in your url
server_ip_address/info.php
Install mysql in a VM and create an Azure Website with a Wordpress image. Then link the mysql db on the virtual machine to the Wordpress site.
Upgrade ClearDB plan to the 10$/month subscription and specify the url of your remote db in wp-config.php

MariaDB on Windows - what is this error when trying to start the database engine?

I am asking this question as an offshoot myself and another SO had from this other MariaDB question:
MariaDB on Windows - getting started help?
When I install MariaDB (v5.2.4), open the command window, navigate to the folder where the files are installed, and type in the following to start the database:
net start mysql
I get the following error:
the service name is invalid
I didn't do anything complex, just ran the installation and tried to get started.
Any ideas?
The error basically tells that installer did not create the service (it currently does not create services), thus you'll need to do it yourself.
start elevated command line
switch to directory of your MariaDB installation (C:\Program Files\MariaDB 5.2.4, something like that)
bin\mysqld --install
and only then
net start mysql
Assuming that there is nothing that runs on port 3306, this will stat.
Alas, the server you will create this way would not be optimized at all.
It is better to create a configuration file my.ini (take a look at MySQL docs and .ini files in the installation directory for examples), and put with performance -related stuff here (innodb bufferpool size etc). With config file, you'll need a different command line to register service (step 3 above):
bin\mysqld --install MySQL --defaults-file=path\to\my.ini
Installer for 5.2.4 is basic indeed. It is being reworked though, new one is going to be better usable.
I installed MariaDB that comes with XAMPP on Windows 10. You will see only mysql in the XAMPP Control Panel. However, if you click Shell on the control panel you can access MariaDB monitor and MariaDB.
Here are some notes:
http://hodentekhelp.blogspot.com/2015/11/how-do-you-access-mariadb-in-xampp.html

Drupal 7 configuration error with Postgresql in Mac OS 10.6.5

I am trying to configure Drupal 7 with Postgres. At the database setup step, I get the following error.
Warning: PDO::_construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in DatabaseConnection->_construct() (line 300 of /Users/shamod/Sites/drupal/7/includes/database/database.inc).
In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.
Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.
Is the database server running?
Does the database exist, and have you entered the correct database name?
Have you entered the correct username and password?
Have you entered the correct database hostname?
NOTE: I am trying to connect to Postgresql but it fails on var/mysql/mysql.sock error. I have setup the database connection string in settings.php for Postgresql. It still does not work.
Any idea?
Evidently you are trying to connect to a MySQL database instance, so you should review your database driver and connection configuration.
Just came up against this error myself when trying to use the web installer - might come down to a similar issue.
On the install page I wasn't given an option to use Postgres driver so I assumed I needed to use the "Mysql (or other)" option. However, looks like the Drupal install script checks which database drivers are compiled into PHP and only offers you what is available - my system didn't have php-pgsql installed by default.
So I needed to install the postgresql drivers to PHP first, reload apache then try the install again.
On CentOS-5:
sudo yum install php-pgsql
sudo service httpd restart
Then reload the install page and all worked fine.

Resources