How can I get back my privilege to create a new database in MySQL? - mysql

I can not use MySQL. MySQL is on my local computer. Currently I added skip-grant-tables in My.ini so I can use MySQL. But I have no privilege to create a new database. My problem is tough, although I asked related questions on SO, but no answer can resolve my problem. I almost give up. So I lower my expectation. I am developing a website, so I need to create database, tables and operate tables. You don't have to consider security. Is there a simple solution that can give me privilege to create a new database? Maybe by adding some command in my.ini or something? You won't need to completely resolve my problem. Maybe after the development, I will upload the database and tables to another server(The current database server is my personal computer, windows XP) so I can uninstall and reinstall MySQL.
The root of problem is that I lack privileges.

I'm not sure if this will work for you, since you might need to have elevated privileges in the first place, but it's worth a shot.
There should be a database called mysql. Take a look in there, and you'll see a table called users. For each record, there's a heap of columns named Select_priv, Insert_priv, etc. For your user record, change each of these to "Y".

It sounds a bit like your installation went astray.
Maybe uninstall/resinstall is your best option, assuming that you've never been able to connect, so there is no data to consider.
Take your time on the installation, and have a look at MySQL Postinstallation Notes

you have 4 questions open about this specific problem. instead of opening duplicates, you should instead update just one of them with new information.
but the simple solution to your problem is to download the ZIP file of mysql for your mysql version from the mysql website and just copy the data\mysql folder in to your data file, then restart the service. this will give you a root user with a blank password that has full access.

Related

Where can I find my mySQL database (using locate doesn't help)?

First ever Stack Overflow post, thanks for your time. Any constructive criticism on how to post better, please just let me know. I have done a search on my query and have found similar posts, but I was unable to use the information within them to resolve my problem.
I have created a mysql database using the terminal window in my Ubuntu system (which I am also new to, having been a lifelong windows user). I used the following code in the terminal window:
$ mysql -u root -p
Then once in mysql, I did the following
CREATE DATABASE securities_master;
USE securities_master;
I created a user and tables in the database using some other code, that doesn't seem relevant here, so I won't bother posting. However, I then decided I would like to take a look at the tables in the database, so I downloaded an SQLite browser. It was at this point that I realized I could not find my database file.
I tried to find the answer on previous stack overflow posts, and tried the suggestions of:
locate sqlite
locate .db
locate .sqlite
locate securities_master
But unfortunately, none of these showed the file I was looking for. The only place I can think of would be what is called the 'root' directory in my computer, but the Ubuntu file manager system won't let me view it because it says I don't have permissions. Is this where it might be?
Could someone shed some light on where I might be able to find this file/database? I know it is definitely there because if I try to CREATE it again, I get the message that it can't because it already exists.
Thanks again.
sqlite and mysql are two different databases. You can't use sqlite on a mysql database. sqlite is a single-file database, in which users just open the file and read and write to it, while mysql is a more traditional relational database system with a server and a client, where the server manages the database (which is generally in a directory of files), while the client just connects to the server.
Where the mysql database is located my depend on your system, but it's usually in /var/lib/mysql. You can look in /etc/mysql/my.cnf for the configuration file, which should have a datadir option that refers to where the actual data for the database is stored.
You can check my.ini file to see where the data folder is located.
Usually there is a folder {mysqlDirectory}/data
MySQL data storage:
Commands.frm
Commands.myd
Commands.myi
The *.frm files contain the table definitions. Your *.myi files are MyISAM index files. Your *.myd files contain the table data.
as mentioned in the answer before mine, mysql and sqlite are two different systems.
You mention you used the cmd line mysql to create the database and then wanted to view the tables. If you're simply trying to see which table are created, in the same command line you used to Create the database you can run show tables;
If you're after a GUI for this, we'd need a bit more context. Is this ubuntu system a remote server, or are you using the desktop version?
You say you're a long time windows user, If you're using windows locally, I personally like SQLWorkbench for accessing my remote mysql servers.
EDIT: I just re-read your post and realised you're using local ubuntu desktop so me mentioning remote was silly, my bad! However, SQLWorkbench does have a ubuntu version at https://dev.mysql.com/downloads/workbench/

"mysql" database restored from another server. Is there a way to "regenerate it"?

last week we were doing a big site migration, dumped around 1200 mysql db and restored them. But in the process, we restored the "mysql" database, and then we lose all the privileges and users that were already created on the new server.
Is there a way to regenerate the mysql database? I dont mind about loosing the users and privileges, but i dont want to bring the old users to this new server.
Thanks in advance for your help.
Sorry to hear that you clobbered your data! Most experienced DBA's do a backup before they do imports like the one you did, because we've all made the mistake you describe at least once.
If you have restarted your MySQL Server since you overwrote the mysql database, then no, you're out of luck. You have overwritten the data and after a restart it is now the official set of users, passwords, and privileges used by that server.
In that case, your only chance is if you have another backup of your old data from before it was overwritten.
If you only overwrote the data, but did not issue FLUSH PRIVILEGES yet, and also if you have not restarted the MySQL Server, then the old grants are still in memory. You can recover them with a tool like pt-show-grants.
Note if you use MySQL 5.7, this temporarily broke pt-show-grants, so you need to use at least version 2.2.20 of Percona Toolkit for the fix (see https://bugs.launchpad.net/percona-toolkit/+bug/1435370 for details).

Exporting drupal site from local host causes missing tables

I have a functional site on my local laptop that I am trying to port to a webhost. Now I was successful in doing this once which must have been a stroke of luck. When an issue forced me to wipe and rebuild, I now find myself unable to migrate the site. Now when I try I get a bunch of errors regarding missing tables.
My process was as follows:
Export mysql table;
FTP website files and sql datatable;
Import sql datatable into new sql database;
Visit the new IP address.
Was I lucky and any way I can fix it? I do not have that much content but I would like to avoid recreating it all.
Please help!
Not sure how helpful I can be without knowing what the specific error messages are.
One thing I can think of is dropping the database and recreating it. Assuming you have command-line access:
mysqladmin drop database_name
mysqladmin create database_name
And then use mysql to import the new dump file. I find this is the safest way as sometimes mysql complains about "duplicate tables" or something similar when you try to restore over the top of an existing database. I can't give any better advice without knowing what the specific errors are.
I suppose you have already done this, but also make sure you server meets the minimum Drupal requirements: https://drupal.org/requirements

MySQL password not taking after new account creation

I'm running MySQL 5.5 on Ubuntu Linux 12.04. I set MySQL up with a root user and two accounts to access the db with using Workbench. The root user works just fine and I can use it to access the DB from Workbench and other programs (like RapidAnalytics), but when I try and access the DB with my other two accounts it will recognize the user, but it won't recognize the password. I know I've entered them correctly, I've reset them a few times, I'm 99.99% certain I'm putting the right password in. On top of that, I've set up both users as DBAs, it made no difference. I made sure they had schema privledges, still nothing (though I may have done that last one wrong. I Just went into the users panel in Workbench and used the wizard they had there...)
I set a MySQL DB up on Windows 7 in the last few days, and that one works just fine. I'm quite certain I followed the same procedure...
At any rate, I have two questions.
Firstly, I read on another thread that this happens sometimes when more than one version of MySQL is installed on Linux. But I'm kind of new to Linux and I'm not sure how to figure out if I have more than one version installed. Can someone please advise if that is a good theory and if so, how to go about checking for what I have installed?
Secondly, well, I'm really just out of ideas. If someone could point me in a good direction...I'm just not sure what to ask Google anymore.

Tool for editing MySQL table permissions?

Is there a tool that makes the task of editing user privileges easier on a MySQL database? I've got nearly 100 tables to work through for 4 users, each with different per-table grants, which is getting tedious via phpMyAdmin. It'll get a lot more irritating when I make changes to the database structure and user list later on. I also can't see a way to do it in MySQL Workbench.
Are there any permissions management tools that make management of table permissions easier?
Update: For clarification, I need a tool that can manage the per-schema and per-table permissions for a user. I'll be changing permissions later, so it needs to be able to fully manage existing permissions as well as grant new ones. MySQL Workbench allows management of per-schema privileges, but not per-table.
Mysql gui tools . See here http://dev.mysql.com/downloads/gui-tools/5.0.html
MySQL Administrator allows you to do all that.
I realize the question is a couple of years old but I came across it while looking for a solution so I suppose others might as well.
I came across SQL Yog and find it capable of doing all that I wanted. I use the community version so it is free to download and its User Manager has the capability to set permissions at the schema and table level.
Workbench is supposed to let you manage users and grant privileges -- see here. You can also use Navicat (not free) or if you are on a mac, Sequel Pro, which is free.
MySQL Workbench provides this functionality.
Open a connection via 'Server Administration'
Click on 'Users and Privileges'
Select the 'Schema Privilegs' tab
Create entries for the schema you're working on, per your needs.
More information here.
Just looked at my install of Squirrel-SQL here. I've only got Oracle databases in this copy of it, but I use it for MySQL at home. Anyway, for Oracle, for tables, it has two tabs: Privileges, and Column Privileges. It may or may not provide similar functionality for MySQL. Give it a look perhaps. (I like it for other database work.)
Try Security Manager tool in dbForge Studio for MySQL (the Security Manager is available in free Express Edition).
In new version multi-user editing is supported; you can select some users and grant or revoke Global and Object (database, tables, fields, ...) privileges, then apply changes or view them in SQL script.
You may want to look at www.securich.com - its an open source user management tool for MySQL.
phpMyAdmin allows table-level privileges. More details can be found, for exemple, here and here.