I want to completely drop an old instance of a MediaWiki and create a new one. I recreated the server side of things and dropped the database which was on AWS RDS.
Now I'm getting errors that X table is not present (at this moment it's an empty database).
Most questions of the sort out there say that one should use the update.php script, but that does not work on an empty database.
How can I create a fresh MediaWiki database (with no content)?
The solution for me was to use the PHP CLI to run the install script. To do this one needs to delete or move the file LocalSettings.php away first, then go to the directory where the MediaWiki was unpacked and run php maintenance/install.php.
The mandatory arguments are the name of the wiki and the name of the admin, but as I already had a database created elsewhere I added the relevant options:
php maintenance/install.php --dbuser myuser --dbpass mypassword --dbname mydb --dbserver mydbserver.rds.amazonaws.com --with-extensions --pass myadminpassword mywiki myadmin
Related
I have a SQL script which selects data from DB and stores it to files. I am unable to create a directory to store these files.
I have shell script that loads the SQL file. Shell and the SQL are on separate server than MySQL db. I would prefer to create this directory using SQL as I want to avoid ssh.
Any suggestions? Surprisingly I couldn't find anything on Google.
I will assume that you're using mysql, according to your tags. You could do it with a Microsoft SQL Server or Oracle database but unfortunately, at the moment, there is no solution to create a directory from MySQL.
Some will guide you with a workaround based on the creation of a data directory, I wouldn't recommand this, as it could lead to performances issues in the future, or worst.
The best solution would be to use a script (java, vbscript, SSH, batch, ...). Again, you won't be able to start this script within your SQL query easily. I know that's no good news, but it is important not to lead you on the wrong direction.
I would suggest to reverse your thinking, and start your SQL query from a script (again, any language you're used to).
I couldn't find any other way other than opening ssh session to the target box.
Open ssh session
Create directory
close ssh session
Load sql file using shell
The sql adds the generated files to the directory created in step 2.
ssh -t $USER#$HOST <<-SSH-END;
mkdir -p "dir/path";
exit;
SSH-END
Sharing just in case someone else needs to do the same.
I have a joomla 2.5 site created locally on my machine, that I've migrated to a vps running nginx, php and mysql. Here is what i did in order:
1. Uploaded all the joomla files in the public_html
2. Changed all the files permission to 644 and all the folders to 755
3. Imported the database.sql to mysql using these commands:
--> mysql> create database databasename;
--> mysql> GRANT ALL PRIVILEGES ON
databasename.* TO username#localhost IDENTIFIED BY 'password';
--> mysql> flush privileges;
--> mysql> exit
--> user#vps:~$ mysql -p -u username database_name < file.sql
I can see all my tables inside the database already, and changed all the needed information on my joomla configuration.php but when i open my site, i get this error:
Table 'databasename.s1t3j0s_session' doesn't exist SQL=INSERT INTO `s1t3j0s_session` (`session_id`, `client_id`, `time`) VALUES ('rh249ehb2tbsqkdff34v177d76', 0, '1357339991')
Where did i got it wrong?
I have migrated wordpress site to the same server with no error.
I've been having trouble with it for weeks. What I needed was a backup copy on my system. However, when I uploaded the database from the remote server onyto my localhost I was getting error messages relating to the session table not existing (the same error that you are getting).
I tried all of the tips relating to deleting and re-creating the tables, but this did not work.
The only solution which worked 100% - which I finally discovered today, was to re-install Joomla 2.5 (I used a fresh install), and then do the following:
Instead of uploading the database from site containing the correct content, instead go through the SQL file itself (i.e. the one you will have exported for upload before encountering problems), and manually process each one of the insert statements into your SQL console directly (I'm using PHPMyadmin). In other words, don't attempt to import the whole file as you normally would. To do this will just result in errors.
For some reason, Joomla 2.5 has an issue with tables that are already populated with data being replaced by a dump file or replacement, sometimes duplicate, data. Hence the need for a fresh install....
Before processing each of the install statements individually (this can take a while - it took me about an hour and a half), go through each of the Joomla tables and make sure that NONE of them are populated with any data whatsoever (therefore when you process the install statements they will not be replacing existing data - because you will have removed all data from populated tables).
So long as you make sure that no INSERTED data has been added to the tables prior to the migration, this will solve your problem.
So to summise:
1/ Get a fresh J2.5 install.
2/ Delete all popolated table data from every joomla table.
3/ Copy and paste each of the insert statements from the exported mysql file containing the correct data. Process each statement individually (this is optional, but highly recommended: to do it this way enables you to counter and pinpoint any individual errors if and when they occur - without having to look through the entire mysql file)
...Go to your site: bingo - it should work!
Make sure the value of $dbprefix in configuration.php under the Joomla directory has the correct value by checking it against the actual db prefix used (open phpMyAdmin and choose the Joomla database to check for this).
Just truncate the data in the session table and do the process again. You have nothing to worry about truncating because there are no valuable data. Session table sometimes messes up stuff.
On Unix, table names are case sensitive. On Windows, they are not. Fun, isn't it? Kinda like their respective file systems. Do you think it's a coincidence?
Caveat: it probably depends on table type; MyISAM.
Field names are case-insensitive regardless.
I had this problem,
in my case, I imported the database through the cpanel and later on got this error message. I later found out that importing database through the cpanel didnot import the tables, just the database name. So I went to the phpmyadmin and import the database there once again, and solved.
I'm customizing a phpUnderControl build file to use the symfony propel:build-sql functionality to generate .sql files to be loaded for every build (not every test). What I am running into is that the resulting .sql files expect the databases to exist, but as part of the build process, I would like to drop and recreate every database found in the schema.yml file to ensure a clean testing environment.
My question is, is it possible to configure propel:build-sql to behave as though I passed the --add-drop-database mysqldump flag?
No it's not possible. It's your job to drop/create the database before you run symfony/propel commands.
I'm considering switching to a new hosting provider, and I would like to transfer my database for my production site to the new hosting provider. I'm using mysql. What are the steps I would need to take to transfer my db?
Appreciate any help.
Thank you,
Brian
Assuming a relatively simple app (PHP, something like that), one app server, one db server, then briefly:
On the new host, create the necessary accounts on the database that you're using on the old host's database.
Copy the app code over.
"Lock" your app on the old host so no data changes can occur (if this is feasible.)
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html is your friend. Dump schema and data, and capture it to a file. Here is the command I used to dump the database exampledb that has the login of example:
mysqldump --add-drop-table -u example -p exampledb > output.sql
(The --add-drop-table makes it easier to re-run the script if you need to later. But it does create a script that will destroy your database, so careful how you run it.)
Now copy (maybe using scp) the output.sql file to your new host.
On the new host, run mysql to build the database with the schema and data from the old host. I use a command like this one, assuming user "example" and a database name of "exampledb":
mysql -u example -p exampledb < output.sql
(Be careful to run this ONLY ON THE NEW HOST. It will obliterate your database.)
The nice thing is, you've got a blank slate of a new machine. You can keep trying different things on that machine without breaking anything.
Turn on the app on new host. Test. If it's been a while, you may need to make changes to get your code up to a newer version of the language. (I did in my case. But maybe you were better about keeping your code up to date.)
Shut down app on old host.
Point DNS/router/whatever to new host.
What'd I miss? (Just went through this moving my silly website to a new machine.)
It's pretty simple, especially for just a single database?
mysqldump followed by a mysqlimport.
MySQL Dump
Generating the .sql file is all you need, because that will contain all of the table information such as CREATE INDEXES, which when you then run through all of your inserts, will add the indexes.
If you struggle with command lines, may I suggest using Navicat Lite. It is free, and is the best GUI that I've seen on the market.
Navicat Lite
Sorry for a noob question regarding MySQL. I downloaded FlightStats to learn about mysql but I can't figure out how to register it with my localhost mysql db. I know in MS SQL you can simply register any sql db using sql studio. I tried to google but come up with no result. Perhaps, my search phrase is wrong. I'm searching with "how to register a mysql database, register a mysql database...etc.". How do you register or setup an database from existing database like FlightStats? I'm using DBVisualizer. Is there a way in dbVis that I'm not aware of to regsiter a database?
Thanks
edit: sorry for the bad wording. I found this. I have the .myd, .myi and .frm and I want to get it to restore(?) with my local mysql instance. I look at all the answers but I'm still confuse as how you restore the database from those 3 files.
A little background first. The FlightStats download page linked to in the original question appears to provide zipped tarballs of the binary table storage files from the MySQL data directory. Given that this is considered a viable means of distribution, and combined with the use of MERGE tables, I would surmise that this tarball contains a bunch of MyISAM data files (.myi, .myd). Jack's edit confirms that this is the situation.
This is an atypical means of distributing a MySQL data set, although not at all uncommon when backing up MyISAM storage, and probably not all that unheard of for moving large data sets around; it likely works out considerably more space-efficient than a corresponding dump file. Of course, in SQL Server land, it's pretty common to attach database files into an instance.
Broadly speaking, you'd recover the database as follows:
Locate the MySQL data directory; typically /var/mysql or similar
Create a new directory with the desired database name e.g. flightdata
Extract the .myi, .myd and other files from the tarball into this directory
Make sure the entire directory is owned by the user MySQL runs as (usually mysql) - use chmod -R to make sure you get everything
Open a MySQL console
USE <database-name>
SHOW TABLES
You should see some tables listed. In addition, the downloads page linked includes a couple of SQL scripts, which contain SQL commands that you need to run against your database once it's in place. These will cause the merge definitions and table indexes to be rebuilt. You can pipe these into the command-line client, e.g. mysql -u<username> -p<password> <database-name> < <sql-file>.
It may be a good idea to shut down the MySQL server while you're doing this; use e.g. /etc/init.d/mysql stop or similar, and restart once the files are extracted in place.
There's generally a way to import sql files using a GUI database tool. I'm not familiar with DBVisualizer, but as long as you have a MySQL command line client installed you can do it there as well. It's pretty easy:
Create a blank schema. You can do this in your GUI tool or on the command line client. Just use CREATE DATABASE flightstats;, or whatever name you want.
Use the following command line syntax to import/run an sql file on the new schema: mysql -u <username> -p flightstats < /path/to/file.sql
The -p option prompts for a password. I generally set up the database using step 1 as the root user, then GRANT some permissions on it to a new user id, then use that user id to run the SQL file.
This process is pretty much what a GUI tool will do in the background.
Registering a database? dont know what that means however mysql gui tools can help you creating a database. Have a look at it or better you download phpmyadmin.
Google WAMP for Windows.
Google MAMP for Mac.
Google LAMP for Linux.
Any questions?