Archive

Archive for the ‘MySQL’ Category

MySQL: Error 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO) [REVISITED]

November 7, 2015 Leave a comment

Have you ever read my 2011 post about this error? Check this before:

https://myotragusbalearicus.wordpress.com/2011/11/21/mysql-error-1045-28000-access-denied-for-user-rootlocalhost-using-password-no/

After that, if you’re still getting the same error, simply try this:

$ mysql -u root -p

You’ll be prompted for root password. Type it and you’re connected to the database.

Please, share your comments below.

Categories: MySQL Tags: , , ,

PHPMyAdmin – Error – Cannot start session without errors

September 19, 2012 Leave a comment

When I access to PHPMyAdmin I get this error:


phpMyAdmin - Error

Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.

My Apache error log shows nothing about PHP errors.

I’ve cleaned up the cookies and not it works.

Categories: apache, MySQL, php Tags: , ,

MySQL: Error 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)

November 21, 2011 36 comments

I’ve upgraded MySQL server version to 5.1.54-1ubuntu4 and when I try to connect to the database I’m getting this error:


$ mysql -u root

Error 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Maybe updating the package the updater overwrote the root password.

To restore it:

  • Stop mysqld deamons.
$ sudo service mysql stop
  • Go  to  mysql/bin directory
$ cd /usr/bin
  • Start a mysql deamon with this option:
$ sudo mysqld_safe --skip-grant-tables
  • Open another terminal and open a mysql session to execute this:
$ mysql
mysql> use mysql;
mysql> UPDATE user SET password=PASSWORD('YOUR_NEW_PASSWORD_HERE') WHERE user = 'root';
mysql> exit;
  • Now kill the mysqld_safe process and restart mysqld normally:
$ sudo service mysql start
Categories: MySQL, ubuntu Tags: , , , ,

Restore MySQL database without a mysqldump backup

September 6, 2011 2 comments

Restore the database

I have had a hard disk error and I need to restore my old redmine database to the newer installation of redmine in Ubuntu 11.04 (https://myotragusbalearicus.wordpress.com/2011/09/05/install-redmine-with-mysql-in-ubuntu-11-04/).

I have the old data directory accessible, but no recent mysqldump of my database, so I just want to copy the old data directory to the newly created redmine database.

First, I take a backup of the current version:

$ mysqldump -u root -p'root_password' redmine | gzip > redmine_mysql.gz

Shutdown the database:


$ sudo service mysql stop

Delete all of MySQL database files (with root user or mysql user):


$ sudo su -

$ cd /var/lib/mysql/

$ rm *

Install a new empty database schema:

$ mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h <machinename> password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/scripts/mysqlbug script!

Start the database and then assign a password to the root user:

$ sudo service mysql start
$ mysqladmin -u root password 'new-password'

Shutdown again the database, and copy all of the files of the old filesystem to the newly created database, overwriting all the files:

$ sudo service mysql stop
$ sudo su -
$ cp -R /old_file_system/var/lib/mysql/* /var/lib/mysql
$ chmod -R 660 /var/lib/mysql/

And finaly, restart the database:

$ sudo service mysql start

Permissions error

If you get this error selecting tables:

mysql> select * from attachments;
ERROR 1017 (HY000): Can't find file: './redmine_default/attachments.frm' (errno: 13)
mysql>

Ensure that you have the propper permissions in the data directory and that belongs to mysql user.
In my case, the data files has the correct permissions:

$ ls redmine_default/attachments.frm
-rw-rw---- 1 mysql mysql  9022 2011-09-06 00:02 attachments.frm

But the directory not:

$ ls redmine_default
drw-rw----  2 mysql mysql     4096 2011-09-06 00:02 redmine_default/

The directory needs 770 permissions:

$ sudo chmod 700 redmine_default

Rollback changes

If something goes wrong, and you need to restore the initial backup, you have to do this:

$ gzip -c -d redmine_mysql.gz | mysql -u root -p redmine

Restore redmine attachments

The attachments are installed under /var/lib/redmine/default/files. To back them up run the following:

</pre>
<code>$ sudo tar zcPf redmine_attachments.tar.gz /old_file_system/var/lib/redmine/default/files</code>

And to extract to the new location:

<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">$ sudo tar xvPf redmine_attachments.tar.gz</span></pre>

Install redmine with MySQL in Ubuntu 11.04

September 5, 2011 19 comments

Damaged hard disk, new hard disk, new re-installation of my software!

Based on my previous post (https://myotragusbalearicus.wordpress.com/2011/03/22/install-redmine-with-mysql-in-ubuntu-10-10/), I reinstalled redmine on Ubuntu 11.04. I also tried to follow http://www.x2on.de/2011/04/23/tutorial-redmine-with-git-and-gitosis-on-ubuntu-11-04/ without installing Git, but have had a lot of problems.

First, install the required packages (Ruby on Rails), apache modules, and then install redmine:

$ sudo apt-get install ruby rubygems subversion ruby-pkg-tools ruby1.8-dev build-essential apache2-prefork-dev libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl libcurl4-openssl-dev ruby  ruby1.9.1-dev libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rake libmysqlclient15-dev
$ sudo apt-get install libapache2-mod-passenger
$ sudo apt-get install redmine redmine-mysql

If you like Gantt-charts:

$ sudo apt-get install librmagick-ruby1.8

Create the database for redmine:

$ mysql -u root -p
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine_password';
GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';

Configure the database settings:

$ cd /usr/share/redmine
$ sudo cp templates/database.yml.template config/database.yml
$ sudo vi config/database.yml

Sample config file using the default MySQL port (3306):

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: redmine_password
  encoding: utf8

Install Rubygem, because Ubuntu 11.04 has an older version:

$ cd /tmp
$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz
$ tar xvfz rubygems-1.7.2.tgz
$ cd rubygems-1.7.2
$ sudo mv /usr/bin/gem /usr/bin/gem-ubuntu
$ sudo ruby setup.rb
RubyGems 1.7.2 installed

=== 1.7.2 / 2011-04-05

* 1 Bug Fix:
  * Warn on loading bad spec array values (ntlm-http gem has nil in its cert
    chain)

------------------------------------------------------------------------------

RubyGems installed the following executables:
	/usr/bin/gem1.8
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Now install Rails and rack

$ sudo gem install rails -v=2.3.11
$ sudo gem install rack -v=1.1.0
$ sudo gem install mysql
$ sudo gem install -v=0.4.2 i18n

Configure redmine:

$ cd /var/www
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
$ sudo chown -R www-data:www-data redmine
$ sudo rake generate_session_store

If you get this error…

rake aborted!
no rakefile found

…just go to the redmine folder and run again… to get this new error:

$ cd /usr/share/redmine
$ sudo rake generate_session_store
NOTE: SourceIndex.new(hash) is deprecated; From /usr/share/redmine/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
uninitialized constant ActiveSupport::Dependencies::Mutex

As stated in Redmine forums http://www.redmine.org/boards/1/topics/22314, i added this line at the beggining of /usr/share/redmine/config/boot.rb:

require 'thread'

And now…

$ sudo rake generate_session_store
NOTE: SourceIndex.new(hash) is deprecated; From /usr/share/redmine/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /usr/share/redmine/lib/tasks/email.rake:170

But this is only a warning, so you can safeliy ignore it.

Let’s go with the next step:

$ sudo RAILS_ENV=production rake db:migrate
NOTE: SourceIndex.new(hash) is deprecated; From /usr/share/redmine/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /usr/share/redmine/lib/tasks/email.rake:170
<strong>rake aborted!</strong>
undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x7f9ea62268b0>

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

That seems to be due to incompatible version of rubygems:

$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.11)
actionpack (2.3.11)
activerecord (2.3.11)
activeresource (2.3.11)
activesupport (2.3.11)
i18n (0.4.2)
mysql (2.8.1)
rack (1.1.2, 1.1.0)
rails (2.3.11)
rake (0.9.2)

$ rails -v
Rails 2.3.11

$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]

Install rubygems update 1.4.2 (and uninstall any other rubygems version you already have):

$ sudo gem install rubygems-update -v='1.4.2'
$ sudo update_rubygems

To get another error…

$ sudo RAILS_ENV=production rake db:migrate
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /usr/share/redmine/lib/tasks/email.rake:170
rake aborted!
No such file or directory - /etc/redmine/default/database.yml

This is more simple!

$ cd /etc/redmine/default
$ sudo ln -s /usr/share/redmine/config/database.yml

And now you finally can configure it:

$ cd /usr/share/redmine
$ sudo RAILS_ENV=production rake db:migrate
$ sudo RAILS_ENV=production rake redmine:load_default_data

And you can test redmine at

http://localhost/redmine

Wow, a little more complicated than in 10.10, at least for me!

Updated 05/april/2012

As commented @ilian, if you have this error:


Please install RDoc 2.4.2+ to generate documentation.

Install it:


gem install rdoc -v=2.4.2

Categories: MySQL, redmine, ubuntu Tags: , , , ,

Install MySQL on Ubuntu

September 5, 2011 Leave a comment
  1. Install the requiered packages
$ sudo apt-get install mysql-server mysql-client mysql-query-browser

To connect to MySQL via command line:

$ mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.1.54-1ubuntu4 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

As an alternative to MySQL Query Browser, you can install PHPMyAdmin, that is widely used in ISP web hostings:

$ sudo apt-get install phpmyadmin

During the installation, you can automatically configure it to run with Apache, if you have already installed (https://myotragusbalearicus.wordpress.com/2011/08/31/install-apache-on-ubuntu/).

Install redmine with MySQL in ubuntu 10.10

March 22, 2011 3 comments

Again with Redmine ;-D

As you can read in my older post about installing redmine with PostgreSQL (https://myotragusbalearicus.wordpress.com/2010/11/17/install-redmine-with-postgresql-in-ubuntu-10-10/), now at home I’ll give it a try with MySQL, as I’m developing a web page with PHP/MySql.

The steps are basically the same, followed the indications of this link:

http://www.redmine.org/wiki/redmine/HowTo_Install_Redmine_in_Ubuntu

I only have had to install and enable the passenger mod for Apache:


$ sudo apt-get install libapache2-mod-passenger

Then, I can access to localhost/redmine, and don’t forget the admin/admin user/password!