Archive

Posts Tagged ‘mysql’

homebrew + mysql = installed but access denied for root

November 14th, 2011 rupert No comments

1. Cleanup
I have an existing mysql @ /usr/local/mysql, so we remove that.

% sudo rm -rf mysql-5.1.43-osx10.6-x86_64

Note: I suggest you backup your mysql data by doing mysqldump prior to removing the old mysql.

2. Install mysql

#brew install mysql
Set up databases to run AS YOUR USER ACCOUNT with:
    unset TMPDIR
    mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
 
To set up base tables in another folder, or use a different user to run
mysqld, view the help for mysqld_install_db:
    mysql_install_db --help
 
and view the MySQL documentation:
  * http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
  * http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
 
To run as, for instance, user "mysql", you may need to `sudo`:
    sudo mysql_install_db ...options...
 
Start mysqld manually with:
    mysql.server start
 
    Note: if this fails, you probably forgot to run the first two steps up above
 
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
 
To connect:
    mysql -uroot
 
To launch on startup:
* if this is your first install:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/Cellar/mysql/5.5.15/com.mysql.mysqld.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
 
* if this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
    cp /usr/local/Cellar/mysql/5.5.15/com.mysql.mysqld.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
 
You may also need to edit the plist to use the correct "UserName".
 
Warning: m4 macros were installed to "share/aclocal".
Homebrew does not append "/usr/local/share/aclocal"
to "/usr/share/aclocal/dirlist". If an autoconf script you use
requires these m4 macros, you'll need to add this path manually.
==> Summary
/usr/local/Cellar/mysql/5.5.15: 6277 files, 217M, built in 4.9 minutes
brew install mysql  498.39s user 83.40s system 135% cpu 7:08.37 total
~/Desktop% unset TMPDIR
~/Desktop% echo $TMPDIR
 
~/Desktop% mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
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/local/Cellar/mysql/5.5.15/bin/mysqladmin -u root password 'new-password'
/usr/local/Cellar/mysql/5.5.15/bin/mysqladmin -u root -h rupert-imac password 'new-password'
 
Alternatively you can run:
/usr/local/Cellar/mysql/5.5.15/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/local/Cellar/mysql/5.5.15 ; /usr/local/Cellar/mysql/5.5.15/bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/Cellar/mysql/5.5.15/mysql-test ; perl mysql-test-run.pl
 
Please report any problems with the /usr/local/Cellar/mysql/5.5.15/scripts/mysqlbug script!
~/Desktop% which mysql.server
/usr/local/bin/mysql.server
~/Desktop% ls -la `which mysql.server`
lrwxr-xr-x  1 rupert  admin  39 30 Dec 11:20 /usr/local/bin/mysql.server@ -> ../Cellar/mysql/5.5.15/bin/mysql.server
~/Desktop% mysql.server start
Starting MySQL
.. SUCCESS!

3. That’s it? No.

At the time of writing this, mysql is at 5.5 and was installed successfully by homebrew. However, I cannot login using the root account. Have a read of this stackoverflow: brew install mysql on mac os.

To fix this, stop mysql

launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

and start mysql by skipping the grant tables.

mysqld_safe --skip-grant-tables

Depending if you have a record in mysql.user (select * from mysql.user), then you can either create or update the user.

create:

GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY 'whatever' WITH GRANT OPTION;
FLUSH PRIVILEGES;

update:

UPDATE mysql.user SET Password = PASSWORD('NewPassword') WHERE User='root';
FLUSH PRIVILEGES;

4. Cleanup paths
This is just removing the pgsql and mysql from the current path

export PATH=$PATH:$ORACLE_HOME:$MYSQL_HOME/bin:$CLANG_HOME:$ANDROID_HOME/tools:$APACHE2_HOME/bin:$MAGICK_HOME/bin:$SPHINX_HOME/bin:$PGSQL_HOME/bin
Categories: homebrew, mysql, osx Tags: , ,

how to use a schema name in mysql2psql

August 8th, 2011 rupert No comments

Below is a summary of my experiences with migrating from MySQL to Postgres using mysql2psql – https://github.com/maxlapshin/mysql2postgres

%gem install mysql2psql

To migrate a “tsa” database from mysql to postgres, create a tsa.yml

mysql:
 hostname: localhost
 port: 3306 
 socket: /tmp/mysql.sock
 username: dbadmin 
 password: password
 database: tsa
 
destination:
 # if file is given, output goes to file, else postgres
 #file: tsa.dump
 postgres:
  hostname: localhost
  port: 5432 
  database: tsa:hotels #database_name:schema_name
  username: dbadmin
  password: password
 
# if tables is given, only the listed tables will be converted.  leave empty to convert all tables.
#tables:
#- table1
#- table2
# if exclude_tables is given, exclude the listed tables from the conversion.
#exclude_tables:
#- table3
#- table4
 
# if supress_data is true, only the schema definition will be exported/migrated, and not the data
supress_data: false
 
# if supress_ddl is true, only the data will be exported/imported, and not the schema
supress_ddl: false
 
# if force_truncate is true, forces a table truncate before table loading
force_truncate: false

Run.

%mysql2psql tsa.yml

References:
http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL

Categories: mysql, postgres Tags: ,

Debian MySQL

October 30th, 2007 rupert No comments

A default install of mysql on debian would have bind-address set to 127.0.0.1. This is why you can’t accept remote connections to your mysql. In order to establish remote connections to mysql on debian servers, please comment the bind-address as shown below.

 42 language    = /usr/share/mysql/english
 43 skip-external-locking
 44 #
 45 # Instead of skip-networking the default is now to listen only on
 46 # localhost which is more compatible and is not less secure.
 47 #bind-address = 127.0.0.1
 48 #
Categories: debian, mysql Tags: ,

Java Thread MySQL Error

May 14th, 2007 rupert No comments

My java thread bails on me after a few hours. I get the ff errors from my log4j. Anyway, I tried upgrading the mysql-java-connector to mysql-connector-java-5.0.5-bin.jar. And added “autoreconnect=true” in the url string… url=jdbc:mysql://127.0.0.1:3306/cncphs?autoreconnect=true.

   1086 java.io.EOFException
   1087
   1088 STACKTRACE:
   1089
   1090 java.io.EOFException
   1091     at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1895)
   1092     at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2342)
   1093     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2838)
   1094     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1584)
   1095     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1675)
   1096     at com.mysql.jdbc.Connection.execSQL(Connection.java:2295)
   1097     at com.mysql.jdbc.Connection.execSQL(Connection.java:2228)
   1098     at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
   1099     at DBThread.run(DBThread.java:45)
   1100
Categories: java Tags: ,

Mapinfo8 MySQL5 Connection

February 20th, 2007 rupert No comments

I only tried this using point objects.

1. Download and install MyODBC3.5.1

2. Create database mapinfotest

3. Create the mapinfo_mapcatalog table as follows:

CREATE TABLE `mapinfo_mapcatalog` (
`SpatialType` float NOT NULL default '0',
`TableName` char(32) NOT NULL default '',
`OwnerName` char(32) NOT NULL default '',
`SpatialColumn` char(32) NOT NULL default '',
`DB_X_LL` float NOT NULL default '0',
`DB_Y_LL` float NOT NULL default '0',
`DB_X_UR` float NOT NULL default '0',
`DB_Y_UR` float NOT NULL default '0',
`CoordinateSystem` char(254) NOT NULL,
`Symbol` char(254) NOT NULL default '',
`XColumnName` char(32) NOT NULL default '',
`YColumnName` char(32) NOT NULL default '',
PRIMARY KEY (`TableName`,`OwnerName`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

4. create a sample table with two (2) decimal columns for the latitude and longitude.

CREATE TABLE `poi_orig2` (
`poiid` decimal(10,0) unsigned NOT NULL default '0',
`id` char(10) NOT NULL default '',
`py_name` char(255) character set utf8 default NULL,
`latitude` decimal(20,8) default '0.00000000',
`longitude` decimal(20,8) default '0.00000000',
PRIMARY KEY (`poiid`,`id`)
)

5. Open Mapinfo 8
6. File -> Open DBMS Connection

7. Table > Maintenance > Make DBMS Table Mappable

Fill up the necessary values for the x,y and the index column.

You need to choose an index column so Mapinfo could update the record/s in MySQL, normally it would be an ID. Once successful you should be able to see the success window…

8. Open the table

Click on the upper right corner to open a dbms connection. After selecting the datasource (mine is system) then it would give you a list of tables to choose from.

Categories: mapinfo Tags: ,